如何把vue中state的值赋值给data
2 回答

LEATH
TA贡献1936条经验 获得超6个赞
你应该把你获取数据的代码放到 created 或者 ready这些Vue的生命周期里。 例如
require('../../../../res.js');
export default {
data() {
return (
noticeList: []
)
},
created: function(){
var self = this;
res.notice.get_list(null, function(error, notices){
self.noticeList = notices;
}
}
}

米脂
TA贡献1836条经验 获得超3个赞
<template>
<div v-progress="{this.SET:SET}"></div>
</template>
<script>
methods:{
...mapMutations(['SET'])
},
directives:{
inserted:function(el , binding){
//通过这个SET方法,传个参数,去改变值
binding.value.SET(1);
}
}
</script>
添加回答
举报
0/150
提交
取消