我正在尝试使用来自 mixin 的全局信息。我打算访问getNow
组件中的计算道具,但它似乎是undefined
.
主.js:
Vue.mixin({
data: function() {
return {
chainBoxURL: "http://172.22.220.197:18004/jsonrpc"
}
},
computed: {
getNow() {
const today = new Date();
const date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
const time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
const dateTime = date + ' ' + time;
return dateTime;
}
}
})
零件:
methods: {
getChainAddress(form) {
if (form.password == form.password_again && form.password != '') {
console.log(this.getNoW)
}
}
}