基本信息
源码名称:vuexDemo
源码大小:0.40M
文件格式:.zip
开发语言:js
更新时间:2020-09-30
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

<template>
  <div id="app">


    <div>{{person.name}}</div>
    <div>{{person.age}}</div>
    <button @click="deleteProperty()">删除姓名(响应式)</button>
    <button @click="deleteProperty1()">删除姓名(非响应式)</button>



  </div>
</template>

<script>
export default {
  name: 'App',
  data(){
    return{
      person:{
        name:"wangjuncehn",
        age: 22
      }
    }
  },
  methods:{
    deleteProperty(){
      this.$delete(this.person,"name");
      console.log(this.person);
    },
    deleteProperty1(){
      delete this.person.name;
      console.log(this.person);
    },
    addtion(){
      this.$store.commit('increament');
      // this.$store.state.counter  
    },
    decreament(){
      this.$store.commit('decreament');
    },
    addCount(count){
      // 提交风格一
      // this.$store.commit('increamentCount',count);
      // 提交风格二
      this.$store.commit({
        type:'increamentCount',
        count
      })
    },
    addStudent(){
      const stu = {id:5,name:'alen',age:26};
      this.$store.commit('addStudent',stu);
    },
    changeInfo(){
      this.$store.dispatch('aupdateInfo','我是payloa')
    },
    changeName(){
      // this.$store.commit("updateName",'wangjunchen');
      this.$store.dispatch('updateName1',"更改完成").then((res)=>{
        console.log(res);
      })
    }

  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>