如何把vue中state的值賦值給data
2 回答

LEATH
TA貢獻1936條經(jīng)驗 獲得超7個贊
你應(yīng)該把你獲取數(shù)據(jù)的代碼放到 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條經(jīng)驗 獲得超3個贊
<template>
<div v-progress="{this.SET:SET}"></div>
</template>
<script>
methods:{
...mapMutations(['SET'])
},
directives:{
inserted:function(el , binding){
//通過這個SET方法,傳個參數(shù),去改變值
binding.value.SET(1);
}
}
</script>
添加回答
舉報
0/150
提交
取消