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 VueRouter from "vue-router";
|
||||||
import Home from "../views/Home.vue";
|
import Home from "../views/Home.vue";
|
||||||
|
|
||||||
|
import Login from "../views/public/Login.vue";
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
Vue.use(VueRouter);
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
@ -11,12 +13,9 @@ const routes = [
|
|||||||
component: Home
|
component: Home
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/about",
|
path: "/public/login",
|
||||||
name: "About",
|
name: "Login",
|
||||||
// route level code-splitting
|
component: Login
|
||||||
// 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")
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -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>
|
<template>
|
||||||
<div class="home">
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// @ is an alias to /src
|
// @ is an alias to /src
|
||||||
import { mapState } from "vuex";
|
// import { mapState, mapActions, mapMutations } from 'vuex';
|
||||||
import * as types from "../store/type";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Home",
|
name: "Home",
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([types.COUNT])
|
// ...mapState({
|
||||||
|
// count: (state) => state.count.count,
|
||||||
|
// }),
|
||||||
},
|
},
|
||||||
components: {}
|
watch: {},
|
||||||
|
methods: {
|
||||||
|
// ...mapActions('count', ['asyncAdd']),
|
||||||
|
// ...mapMutations('count', ['setCount']),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user