我想使用vuejs有一個模式窗口,並將其隱藏在putton按下。 下面是一些代碼: 的index.html:數據不會更新accordint相關道具的價值
<table class="table">
<tr v-for = "dream in dreams">
...
<th>
<button id="show-modal" @click="showModal = true">New Post</button>
</th>
</tr>
</table>
...
<editdream v-bind:show.sync="showModal"></editdream>
在editdream.vue文件我有:
<template>
<div v-show="isShown" transition="modal">
...
</div>
</template>
<script>
export default {
props: ['show'],
methods: {
close: function() {
this.isShown = false;
},
savePost: function() {
this.close();
}
},
data: function() {
return { isShown: this.show }
}
}
我認爲,當我按下按鈕,然後 '秀'道具將更新爲模態窗口,相應的「isShown」數據也將被更新。但我只能看到道具變得真實,但按下按鈕時顯示仍然是錯誤的。你能解釋一下爲什麼?
這是一個寫得很好的問題。我建議的唯一改進就是提到一兩件事你試圖解決這個問題。歡迎來到堆棧溢出! – Sethmr
請告訴我們你使用的VueJS版本 - 'v-bind'上的'sync'修飾符在Vue 2 –
中已棄用感謝您的評論,soltuion被發現我使用「computed」而不是數據。看到我下面的評論。 –