Computed property was assigned to but it has no setter问题解决

报这个是因为在computed中定义了某个属性,只有一个return额,而你在其他地方又对这个属性赋值了就会报这个,比如这样

mounted(){
	this.submit()
},
computed: {
	setName(){
		return this.form.name
	}
},
methods: {
	submit() {
		this.setName = 'zhangsan'
	}
}

这样修改一下就好了

computed: {
	setName(){
		
		get(){
            return this.form.name
        },
        set(value) {
           this.setName = value
        }
	}
},

你可能感兴趣的:(vue的那些事,javascript,开发语言,vue.js)