Commit 5985e448 authored by huanglu's avatar huanglu

update

parent bc471b74
This diff is collapsed.
<template>
<div id="app">
<router-link to="/setting"> setting </router-link>
<keep-alive>
<router-view v-if="$route.meta.keepAlive"/>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"/>
</div>
</template>
<script>
export default {
mounted() {
},
methods: {
},
};
</script>
<style lang="less" scoped>
.demo {
.toRpx(font-size, 50);
display: inline-block;
.toRpx(height, 375);
.border;
}
</style>
import { get, post } from '@/utils/request';
export const login = (username, password) => post('/login', { username, password });
export const userinfo = (params) => get('/userinfo', params);
<template>
<div class="hello">
this is helloworld components
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String,
}
};
</script>
<style scoped lang="less">
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
import Vue from 'vue';
import App from './App.vue';
import router, { multiRouter } from './router';
import store from './store';
Vue.config.productionTip = false;
console.log([1,2,3].includes(12))
new Vue({
router,
store,
render: (h) => h(App),
}).$mount('#app');
\ No newline at end of file
import Vue from "vue";
import VueRouter from "vue-router";
const Cart = () => import('../views/about');
const Setting = () => import('../views/setting')
Vue.use(VueRouter);
// 单入口路由配置
const routes = [
{
path: "/cart",
name: "Cart",
component: Cart
},
{
path: '/setting',
name: 'setting',
component: Setting
}
];
const router = new VueRouter({
mode: "hash",
base: process.env.BASE_URL,
routes
});
export default router;
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
const reqiureContext = require.context('./modules', false, /\.js$/);
const modules = {};
reqiureContext.keys().forEach((key) => {
const name = key.slice(2, -3); // 得到 state的名称
const moduleConfig = reqiureContext(key).default || reqiureContext(key);
modules[name] = moduleConfig;
});
export default new Vuex.Store({
modules: {
...modules,
},
});
const state = {
username: 'zhaoting',
address: '',
token: '',
};
const mutations = {
changeName(state, payload) {
state.username = payload;
},
};
const getters = {
currentUsername: (state) => state.username,
};
export default {
state,
getters,
mutations,
};
const state = {
carts: [],
};
const actions = {
addCart({ commit, state }, cart) {
setTimeout(() => {
commit('addCart', cart);
}, 1000);
},
deleteCart({ commit }, id) {
setTimeout(() => {
commit('deleteCart', id);
}, 1000);
},
deleteAll({ commit }) {
setTimeout(() => {
commit('deleteAll');
}, 1000);
},
};
const mutations = {
addCart(state, product) {
const { carts } = state;
carts.push(product);
state.carts = [...carts];
},
deleteCart(state, id) {
const carts = [...state.carts.filter((cart) => cart.id !== id)];
state.carts = carts;
},
deleteAll() {
state.carts = [];
},
};
export default {
state,
mutations,
actions,
};
<template>
<div class="about">
</div>
</template>
<template>
<div>
</div>
</template>
<script>
import hello from '@pages/perosn/components/hello-world'
export default {
components: {
hello
},
data() {
return {};
},
mounted() {
}
}
</script>
<style>
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment