-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
310 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
module.exports = { | ||
presets: [ | ||
'@vue/app' | ||
], | ||
plugins: [ | ||
['import', { | ||
libraryName: 'vant', | ||
libraryDirectory: 'es', | ||
style: true | ||
}, 'vant'] | ||
] | ||
} | ||
/* | ||
'postcss-pxtorem': { | ||
rootValue: 37.5, | ||
propList: ['*'] | ||
} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
module.exports = { | ||
plugins: { | ||
autoprefixer: {} | ||
autoprefixer: { | ||
overrideBrowserslist: ['Android >= 4.0', 'iOS >= 7'] | ||
}, | ||
'postcss-pxtorem': { | ||
rootValue: 75, | ||
propList: ['*'] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default [ | ||
{ | ||
path: '/about', | ||
name: 'about', | ||
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue') | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Vue from 'vue' | ||
import Router from 'vue-router' | ||
import Home from '../views/Home.vue' | ||
|
||
Vue.use(Router) | ||
|
||
let routes = [ | ||
{ | ||
path: '/', | ||
name: 'home', | ||
component: Home | ||
} | ||
] | ||
|
||
const routerContext = require.context('./', true, /\.js$/) | ||
routerContext.keys().forEach(route => { | ||
// 如果是根目录的 index.js 、不处理 | ||
if (route.startsWith('./index')) { | ||
return | ||
} | ||
const routerModule = routerContext(route) | ||
/** | ||
* 兼容 import export 和 require module.export 两种规范 | ||
*/ | ||
routes = routes.concat(routerModule.default || routerModule) | ||
}) | ||
const myRouter = new Router({ | ||
mode: 'history', | ||
base: process.env.BASE_URL, | ||
routes | ||
}) | ||
|
||
myRouter.beforeEach((to, from, next) => { | ||
if (to.params.direction) { | ||
store.commit('updateDirection', to.params.direction) | ||
} else { | ||
const toIndex = history.getItem(to.path) | ||
const fromIndex = history.getItem(from.path) | ||
// 判断并记录跳转页面是否访问过,以此判断跳转过渡方式 | ||
if (toIndex) { | ||
if (!fromIndex || parseInt(toIndex, 10) > parseInt(fromIndex, 10) || (toIndex === '0' && fromIndex === '0')) { | ||
store.commit('updateDirection', 'forward') | ||
} else { | ||
store.commit('updateDirection', 'back') | ||
} | ||
} else { | ||
++historyCount | ||
history.setItem('count', historyCount) | ||
to.path !== '/' && history.setItem(to.path, historyCount) | ||
store.commit('updateDirection', 'forward') | ||
} | ||
} | ||
next() | ||
}) | ||
|
||
export default myRouter |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Vue from 'vue' | ||
import Vuex from 'vuex' | ||
import test from './modules/test' | ||
|
||
Vue.use(Vuex) | ||
|
||
export default new Vuex.Store({ | ||
state: { | ||
msg: 'hello vuex', | ||
loading: false | ||
}, | ||
getters: { | ||
loading (state) { | ||
return state.loading | ||
} | ||
}, | ||
mutations: { | ||
setMsg (state, msg) { | ||
state.msg = msg | ||
}, | ||
setLoading (state, val) { | ||
state.loading = val | ||
} | ||
}, | ||
actions: { | ||
|
||
}, | ||
modules: { | ||
test | ||
} | ||
}) | ||
|
||
/* | ||
this.$store.registerModule('d',{ | ||
}) | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const state = { | ||
number: 1 | ||
} | ||
const actions = { | ||
onePlusAction: async ({ commit }, { val }) => { | ||
commit('setLoading', true, { root: true }) | ||
// loading状态 | ||
await setTimeout(() => { | ||
commit('onePlus', val) | ||
commit('setLoading', false, { root: true }) | ||
}, 1500) | ||
} | ||
} | ||
const mutations = { | ||
onePlus (state, val = 1) { | ||
state.number = state.number + val | ||
} | ||
} | ||
const getters = { | ||
|
||
} | ||
export default { | ||
namespaced: true, | ||
state, | ||
actions, | ||
mutations, | ||
getters | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,7 @@ | |
<h1>This is an about page</h1> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
} | ||
</script> |
Oops, something went wrong.