【发布时间】:2018-02-14 15:23:46
【问题描述】:
<script>
import alertStore from '../stores/alert';
Vue.component('alert', require('vue-strap').alert);
export default {
data () {
return {
show: alertStore.state.show,
title: alertStore.state.title,
msg: alertStore.state.msg,
type: alertStore.state.type
}
},
created () {
},
computed: {
title () {
return alertStore.state.title;
},
msg () {
return alertStore.state.msg;
},
type () {
return alertStore.state.type;
},
show () {
return alertStore.state.show;
},
duration () {
return alertStore.state.duration;
}
},
methods: {
dismissAlert: function () {
this.$store.dispatch('dismissAlert', {title: '...'});
},
}
}
命名空间在 Vue 中是如何工作的?数据键、计算返回对象键和所有组件对象键都将添加到 this 实例中吗?
所以如果我覆盖它。我收到一些错误,例如:
[Vue 警告]:计算属性“title”已在数据中定义。
[Vue 警告]:计算属性“show”已在数据中定义。
[Vue 警告]:计算属性“类型”已在数据中定义。
[Vue 警告]:计算属性“msg”已在数据中定义。
我该如何解决这个问题。
提前致谢。
【问题讨论】:
-
你真的需要使用计算属性吗?或者为什么要在“数据”和“计算”中定义组件的成员?
-
实际上这段代码是由另一个开发人员完成的,我是 vuejs 的新手。我已经阅读了 vueJS 教程,但没有找到任何解决方案,为什么要在数据对象中添加数据。如果我从数据对象中删除返回,则不会出现错误,并且我的模板仍然没有显示。 Vuejs 开发工具显示计算加载:false 知道我能做什么。
-
模板的邮政编码。
-
请检查下面,我已经粘贴了我的完整模板代码。
标签: vuejs2