為什么我添加的數(shù)據(jù)無法顯示到list頁面上???
<template>
<div>
<p>標(biāo)題</p>
<input type="text " v-model= "title" >
<p>內(nèi)容</p>
<input type="text" v-model= "content"><br>
<button ?@click="add">添加</button>
</div>
</template>
<script> ? ?
import store from '@/store'
import { stat } from 'fs';
export default {
data (){
return{
title:"",
content:""
}
},
methods:{
add(){
store.commit("addItems", {
title:this.title,
content:this.content
},
this.title= "" ,
this.content=""
)
}
}
}
</script>
上面是我的add頁面的相關(guān)代碼
下面是我store.js的代碼
然后是我list頁面的代碼
2019-07-18
有沒有錯誤提示?
在add方法里面加個debbugger斷點
點擊了add之后,斷點執(zhí)行,然后去看看dev-tools
2019-07-18
目前代碼問題不大,你確定?你的store.js在你的src目錄下?一定要在src目錄下才可以使用@代替