我現在有三個步驟需要依次顯示,因此我創建了三個組件 - 每個步驟都有一個組件。如何用組件定義屬性?
我app.js文件:
import LocationList from './components/LocationList.vue';
import ChooseTime from './components/ChooseTime.vue';
import ChooseMethod from './components/ChooseMethod.vue';
Vue.component('location-list', LocationList);
Vue.component('choose-time', ChooseTime);
Vue.component('choose-method', ChooseMethod);
let store = {
isVisible: {
steps: {
one: true,
two: false,
three: false,
}
}
};
new Vue({
el: '#app-order',
data: store,
router
});
現在,當我的唯一途徑是所謂的,從「VUE-路由器
進口VueRouter;
let routes = [
{
path: '/order',
component: require('./views/Order.vue')
}
];
export default new VueRouter({
routes
});
所有這些組件都正確加載。問題是,當我嘗試v-show
逐一時間:
Order.vue:
<template>
// ...
<location-list v-show="isVisible.steps.one"></location-list>
<choose-time v-show="isVisible.steps.two"></choose-time>
<choose-method v-show="isVisible.steps.three"></choose-method>
// ...
</template>
<script>
</script>
<style>
</style>
我收到的錯誤消息是:
[Vue warn]: Property or method "isVisible" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
但是當我檢查中Vue公司的瀏覽器擴展,isVisible是在根元素中定義的?
正如你可以看到它是根元素,但沒有訂單視圖中雖然。
感謝您的幫助!
在步驟組件模板之一中引用'isVisible'嗎? – Bert
不,我只是有一個基本的文件結構像''。我沒有在其中的任何地方引用'isVisible' – Chris
到目前爲止,我沒有看到有什麼問題。 – Bert