Vue路由使用笔记
July 9, 2022 •
Comment
//vuex store
//引入 Vuex , Vue
import Vuex from "vuex";
import Vue from "vue";
Vue.use(Vuex);
//准备 actions 用于响应组件中的动作
const actions = {};
//用于操作数据(state)
const mutations = {};
//用于存储数据
const state = {};
//创建 store 并暴露
export default new Vuex.Store({
actions,
mutations,
state,
});
import Vue from "vue";
import App from "./App.vue";
import Vuex from "vuex";
import store from "./store/index.js";
Vue.config.productionTip = false;
Vue.use(Vuex);
new Vue({
render: (h) => h(App),
store,
}).$mount("#app");
new Vue({
directives:{指令名:配置对象}
})
//or
new Vue({
directives:{指令名:回调函数}
})
Vue.directives(指令名,配置对象)
//or
Vue.directives(指令名,回调函数)
这三个回调函数中的 this 都指向 windows,简写形式只能定义 bind 和 update 两个回调