Browse Source

添加工具类

master
spirit2020 3 years ago
parent
commit
f1d40c49eb
  1. 12
      App.vue
  2. 9
      common/expands/Route.js
  3. 9
      common/expands/Toast.js
  4. 8
      common/expands/index.js
  5. 1
      common/mixins/readme.txt
  6. 11
      main.js

12
App.vue

@ -1,14 +1,8 @@
<script>
export default {
onLaunch: function() {
console.log('App Launch')
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
onLaunch: function() {},
onShow: function() {},
onHide: function() {}
}
</script>

9
common/expands/Route.js

@ -0,0 +1,9 @@
function Back (duration = 1500) {
setTimeout(() => {
uni.navigateBack()
}, duration)
}
export default {
Back
}

9
common/expands/Toast.js

@ -0,0 +1,9 @@
function Toast(title, icon = 'none', options) {
uni.showToast({
title,
icon,
...options
})
}
export default Toast

8
common/expands/index.js

@ -0,0 +1,8 @@
import Toast from './Toast.js'
import Route from './Route.js'
export default function install (Vue) {
Vue.prototype.$toast = Toast
for (let key in Route) Vue.prototype[`$${key}`.toLowerCase()] = Route[key]
}

1
common/mixins/readme.txt

@ -0,0 +1 @@
mixin 放这里

11
main.js

@ -1,20 +1,23 @@
import App from './App'
import uView from 'uview-ui';
Vue.use(uView);
import uView from 'uview-ui'
Vue.use(uView)
import Expands from '@/common/expands/index.js'
Vue.use(Expands)
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
import {createSSRApp} from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {

Loading…
Cancel
Save