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. 7
      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 放这里

7
main.js

@ -1,7 +1,10 @@
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'

Loading…
Cancel
Save