English | 简体中文
- Docs address:https://vaq.wangxuefeng.com.cn
-
Description: This project already supports
typescript, just selecttypescriptwhen creating aVueproject -
This project is based on w-xuefeng/vue-cli-plugin-apicloud, run the following command to install
$ vue add @w-xuefeng/apicloud
or
$ npm i @w-xuefeng/vue-cli-plugin-apicloud # or use yarn $ vue invoke @w-xuefeng/apicloud
-
In the
main.js, you can configure options ofpluginincludingpagesanddebugOnPC -
Chaining the
initmethod will create aVueinstance and ensure that it executes afterapiready, returningPromise<CombinedVueInstance<Vue, object, object, object, object>>import App from './App.vue' import Vue from 'vue' import VAQ from 'vue-apicloud-quickstart' import pages from '@/config/pages.json' Vue.config.productionTip = false Vue .use(VAQ, { pages, // debugOnPC: process.env.NODE_ENV !== 'production' }) .init({ el: '#app', render: h => h(App) })
-
1
pages: Page configuration-
Create the
pagesdirectory and theconfigdirectory under thesrcdirectory, assuming that there are existing open screen ad pagesindex/index.vue, login pagelogin/index.vueand application home pagehome/index.vue、webview pagehome/web.vue, the directory structure is as follows:├── src | | │ ├── pages # Page entry | | | | | ├── index | | | | | | | └── index.vue # Open screen advertising page | | | | | ├── login | | | | | | | └── index.vue # Login page | | | | | └── home | | | | | ├── index.vue # APP home page | | | | | └── web.vue # Webview page | | │ └── config # Configuration entry | | | └── pages.json # Page profile | -
The page configuration file
pages.jsonhas the following structure[ { "title": "advertisingPage", "name": "index", "path": "index/index" }, { "title": "loginPage", "name": "login", "path": "login/index" }, { "title": "homePage", "name": "home", "path": "home/index" }, { "title": "webPage", "name": "web", "path": "home/web" } ]
-
-
2
debugOnPC: Debugging on PC-
Recommended scenarios
-
When development page and debugging the style in the early, you could set debugonpc to true, which can be debugged in the PC browser
-
When development and debugging function later, you could set debugOnPC to false, debugging in custom Loader.
-
Or you can always set debugOnPC to false and debug in custom Loader.
-
Note: Make sure debugOnPC is false when compiling and building, otherwise it will affect normal operation after final packaging
-
-
Because apicloud will inject global variables
apiintowindowin apploader or custom loader, the ability to call native modules can be realized throughapiwhen using loader debugging on mobile devices. To ensure that the initialization is completed when calling the native module, all statements calling the native module should be executed in hooks ofapiready. -
When
debugOnPCis the default valuefalse, the instance of Vue page will execute in hooks ofapiready, so the debugging page cannot be previewed in PC browser. -
When
debugOnPCis true,new vue()will be executed directly to create a page instance. At this time, allapirelated statements cannot be executed, but the page content unrelated toapiwill be displayed in the browser normally.
-
