• <noscript id="ggggg"><dd id="ggggg"></dd></noscript>
    <small id="ggggg"></small> <sup id="ggggg"></sup>
    <noscript id="ggggg"><dd id="ggggg"></dd></noscript>
    <tfoot id="ggggg"></tfoot>
  • <nav id="ggggg"><cite id="ggggg"></cite></nav>
    <nav id="ggggg"></nav>
    成人黃色A片免费看三更小说,精品人妻av区波多野结衣,亚洲第一极品精品无码,欧美综合区自拍亚洲综合,久久99青青精品免费观看,中文字幕在线中字日韩 ,亚洲国产精品18久久久久久,黄色在线免费观看

    關于Vuex的全家桶狀態管理(一)

    2018-5-29    seo達人

    如果您想訂閱本博客內容,每天自動發到您的郵箱中, 請點這里

    1:安裝

     npm install vuex --save
        
    • 1

    2: 在main.js 主入口js里面引用store.js

    import Vue from 'vue' import App from './App' import router from './router' import store from './vuex/store' //引用store.js Vue.config.productionTip = false //阻止在啟動時生成生產提示 //vue實例 new Vue({
     el: '#app',
     router,
     store, //把store掛在到vue的實例下面 template: '<App/>',
     components: { App }
    })
        
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    3:在store.js里引用Vuex

    import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) //注冊Vuex // 定義常量  如果訪問他的話,就叫訪問狀態對象 const state = {
      count: 1 } // mutations用來改變store狀態, 如果訪問他的話,就叫訪問觸發狀態 const mutations = { //這里面的方法是用 this.$store.commit('jia') 來觸發 jia(state){
        state.count ++
      },
      jian(state){
        state.count --
      },
    } //暴露到外面,讓其他地方的引用 export default new Vuex.Store({
      state,
      mutations
    })
        
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    4:在vue組件中使用

    使用$store.commit(‘jia’)區觸發mutations下面的加減方法

    <template> <p class="hello"> <h1>Hello Vuex</h1> <h5>{{$store.state.count}}</h5> <p> <button @click="$store.commit('jia')">+</button> <button @click="$store.commit('jian')">-</button> </p> </p> </template> <!-- 加上scoped是css只在這個組件里面生效,為了不影響全局樣式 --> <style scoped> h5{ font-size: 20px; color: red; } </style>
        
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    這里寫圖片描述

    5:state訪問狀態對象

    使用computed計算

    <template> <p class="hello"> <h1>Hello Vuex</h1> <h5>{{count}}</h5> <p> <button @click="$store.commit('jia')">+</button> <button @click="$store.commit('jian')">-</button> </p> </p> </template> <script> import {mapState} from 'vuex' export default{
      name:'hello', //寫上name的作用是,如果你頁面報錯了,他會提示你是那個頁面報的錯,很實用 // 方法一 // computed: { //  count(){ //   return this.$store.state.count + 6 //  } // } // 方法二 需要引入外部 mapState computed:mapState({
       count:state => state.count + 10 }) // ECMA5用法 // computed:mapState({ //  count:function(state){ //   return state.count //  } // }) //方法三 // computed: mapState([ //  'count' // ]) } </script>
    藍藍設計www.lzhte.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務

    日歷

    鏈接

    個人資料

    藍藍設計的小編 http://www.lzhte.cn

    存檔

    主站蜘蛛池模板: 狠狠综合久久综合鬼色| 丰满亚洲大尺度无码无码专线| 精品人妻无码视频中文字幕一区二区三区 | 色哟哟精品视频在线观看| 国产精品自产拍在线观看| 亚洲日本精品va中文字幕| 久久综合一香蕉老鬼色一个| 色悠久久久久综合网香蕉| 亚洲人成77777在线观| 激情一区二区三区视频| 亚洲区精品久久一区二区三区| 亚洲精品国产美女久久久99| 久热香蕉精品视频在线播放| 亚洲性爱一区| 国产精品中文字幕综合| 午夜福利波多野结衣人妻| 草莓AV| 欧美一级日韩一级亚洲一级| 亚洲AV色香蕉一区二区蜜桃| 乌恰县| 国产成人精品2021欧美日韩| 亚洲啊V天堂在线观看2021| 亚洲av无码成人专区| 日本一道一区二区视频| 亚洲第一福利网站在线观看| 国产成AV人片久青草影院| 精品欧美乱码久久久久久1区2区| 国产午夜福利片1000无码| 久久精品| 3d动漫精品啪啪一区二区下载| 成人AV在线一区二区三区| 亚洲日本人成网站在线观看| 日产无码精品一区二区三区 | 五月天无码在线观看| 亚洲人成网站在线播放2019| 日韩夜夜高潮夜夜爽无码| 成人女人看片免费视频放人| 欧美成a人片在线播放| 男人下面疯狂进女人下部视频| 波多野结衣高潮AV在线播放| 国产高颜值露脸在线观看|