From f1d40c49eb8e19277edabd1bb2ab128dfe446604 Mon Sep 17 00:00:00 2001 From: spirit2020 <1194501891@qq.com> Date: Wed, 19 Jan 2022 10:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 12 +++--------- common/expands/Route.js | 9 +++++++++ common/expands/Toast.js | 9 +++++++++ common/expands/index.js | 8 ++++++++ common/mixins/readme.txt | 1 + main.js | 13 ++++++++----- 6 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 common/expands/Route.js create mode 100644 common/expands/Toast.js create mode 100644 common/expands/index.js create mode 100644 common/mixins/readme.txt diff --git a/App.vue b/App.vue index 393f118..76f40f4 100644 --- a/App.vue +++ b/App.vue @@ -1,14 +1,8 @@ diff --git a/common/expands/Route.js b/common/expands/Route.js new file mode 100644 index 0000000..d212fc5 --- /dev/null +++ b/common/expands/Route.js @@ -0,0 +1,9 @@ +function Back (duration = 1500) { + setTimeout(() => { + uni.navigateBack() + }, duration) +} + +export default { + Back +} diff --git a/common/expands/Toast.js b/common/expands/Toast.js new file mode 100644 index 0000000..9ad6629 --- /dev/null +++ b/common/expands/Toast.js @@ -0,0 +1,9 @@ +function Toast(title, icon = 'none', options) { + uni.showToast({ + title, + icon, + ...options + }) +} + +export default Toast diff --git a/common/expands/index.js b/common/expands/index.js new file mode 100644 index 0000000..00fd70d --- /dev/null +++ b/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] +} + diff --git a/common/mixins/readme.txt b/common/mixins/readme.txt new file mode 100644 index 0000000..4f51ebb --- /dev/null +++ b/common/mixins/readme.txt @@ -0,0 +1 @@ +mixin 放这里 \ No newline at end of file diff --git a/main.js b/main.js index 6745b3e..50a09fd 100644 --- a/main.js +++ b/main.js @@ -1,24 +1,27 @@ 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 { app } } -// #endif \ No newline at end of file +// #endif