为什么我添加的数据无法显示到list页面上???

来源:4-4 单页面应用 Demo2(1)

weixin_慕雪8245307

2019-07-16 20:52

<template>

<div>

<p>标题</p>

<input type="text " v-model= "title" >

<p>内容</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页面的相关代码


下面是我store.js的代码

https://img2.mukewang.com/5d2dc8300001c38804040554.jpg

然后是我list页面的代码

https://img3.mukewang.com/5d2dc86300014a8105900618.jpg

写回答 关注

2回答

  • Brian
    2019-07-18 15:48:02
    已采纳

    有没有错误提示?

    在add方法里面加个debbugger断点

    点击了add之后,断点执行,然后去看看dev-tools

    weixin...

    找到了,里面没有加push直接切换到list路由

    2019-07-18 16:22:04

    共 1 条回复 >

  • 小二黑er
    2019-07-18 14:48:05

    目前代码问题不大,你确定?你的store.js在你的src目录下?一定要在src目录下才可以使用@代替

    weixin...

    问题找到了,按钮上忘了加事件,push到list 路线

    2019-07-18 16:23:03

    共 1 条回复 >

3小时速成 Vue2.x 核心技术

带你快速学习最流行的前端框架vue2.x的核心技术

82560 学习 · 487 问题

查看课程

相似问题