feat:vue前端构建
This commit is contained in:
parent
aae34e0691
commit
e89993073c
@ -2,6 +2,8 @@ import Vue from "vue";
|
||||
import VueRouter from "vue-router";
|
||||
import Home from "../views/Home.vue";
|
||||
|
||||
import Login from "../views/public/Login.vue";
|
||||
|
||||
Vue.use(VueRouter);
|
||||
|
||||
const routes = [
|
||||
@ -11,12 +13,9 @@ const routes = [
|
||||
component: Home
|
||||
},
|
||||
{
|
||||
path: "/about",
|
||||
name: "About",
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () => import(/* webpackChunkName: "about" */ "../views/About.vue")
|
||||
path: "/public/login",
|
||||
name: "Login",
|
||||
component: Login
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -1,32 +0,0 @@
|
||||
import * as types from "../type";
|
||||
|
||||
const state = {
|
||||
[types.COUNT]: 0
|
||||
};
|
||||
|
||||
const getters = {};
|
||||
|
||||
const actions = {
|
||||
asyncAdd({ commit }, data) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
commit(types.TEST, data);
|
||||
resolve();
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
[types.COUNT](state1, data) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
state1[types.COUNT] += data;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
};
|
@ -1,19 +1,29 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
{{ count }}
|
||||
<!-- {{ count}}
|
||||
<div><button @click="setCount(1)">增加1</button></div>
|
||||
<div><button @click="asyncAdd(10)">异步增加</button></div>
|
||||
<Button type="primary">button</Button> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// @ is an alias to /src
|
||||
import { mapState } from "vuex";
|
||||
import * as types from "../store/type";
|
||||
// import { mapState, mapActions, mapMutations } from 'vuex';
|
||||
|
||||
export default {
|
||||
name: "Home",
|
||||
computed: {
|
||||
...mapState([types.COUNT])
|
||||
// ...mapState({
|
||||
// count: (state) => state.count.count,
|
||||
// }),
|
||||
},
|
||||
components: {}
|
||||
watch: {},
|
||||
methods: {
|
||||
// ...mapActions('count', ['asyncAdd']),
|
||||
// ...mapMutations('count', ['setCount']),
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
Loading…
x
Reference in New Issue
Block a user