项目作者: w-xuefeng

项目描述 :
:rocket: Vue 与 apicloud 齐飞, web 共 原生一色!
高级语言: TypeScript
项目地址: git://github.com/w-xuefeng/vue-apicloud-quickstart.git
创建时间: 2018-09-15T15:27:10Z
项目社区:https://github.com/w-xuefeng/vue-apicloud-quickstart

开源协议:

下载




vue-apicloud-quickstart


The start up of using vue.js + apicloud to develop mobile applications



Github Action
Github Action
npm
npm

English | 简体中文

Documentation

Install

  • Description: This project already supports typescript, just selecttypescript when creating a Vue project

  • This project is based on w-xuefeng/vue-cli-plugin-apicloud, run the following command to install

    1. $ vue add @w-xuefeng/apicloud

    or

    1. $ npm i @w-xuefeng/vue-cli-plugin-apicloud # or use yarn
    2. $ vue invoke @w-xuefeng/apicloud

Usage

  • In the main.js, you can configure options of plugin including pages and debugOnPC
  • Chaining the init method will create aVue instance and ensure that it executes after apiready, returningPromise<CombinedVueInstance<Vue, object, object, object, object>>

    1. import App from './App.vue'
    2. import Vue from 'vue'
    3. import VAQ from 'vue-apicloud-quickstart'
    4. import pages from '@/config/pages.json'
    5. Vue.config.productionTip = false
    6. Vue
    7. .use(VAQ, {
    8. pages,
    9. // debugOnPC: process.env.NODE_ENV !== 'production'
    10. })
    11. .init({
    12. el: '#app',
    13. render: h => h(App)
    14. })

Options

  • 1 pages: Page configuration

    • Create the pages directory and the config directory under the src directory, assuming that there are existing open screen ad pages
      index/index.vue, login page login/index.vue and application home page home/index.vue、webview page home/web.vue, the directory structure is as follows:

      1. ├── src
      2. | |
      3. ├── pages # Page entry
      4. | | |
      5. | | ├── index
      6. | | | |
      7. | | | └── index.vue # Open screen advertising page
      8. | | |
      9. | | ├── login
      10. | | | |
      11. | | | └── index.vue # Login page
      12. | | |
      13. | | └── home
      14. | | |
      15. | | ├── index.vue # APP home page
      16. | | |
      17. | | └── web.vue # Webview page
      18. | |
      19. └── config # Configuration entry
      20. | |
      21. | └── pages.json # Page profile
      22. |
    • The page configuration file pages.json has the following structure

      1. [
      2. {
      3. "title": "advertisingPage",
      4. "name": "index",
      5. "path": "index/index"
      6. },
      7. {
      8. "title": "loginPage",
      9. "name": "login",
      10. "path": "login/index"
      11. },
      12. {
      13. "title": "homePage",
      14. "name": "home",
      15. "path": "home/index"
      16. },
      17. {
      18. "title": "webPage",
      19. "name": "web",
      20. "path": "home/web"
      21. }
      22. ]
  • 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 apiinto window in apploader or custom loader, the ability to call native modules can be realized through api when 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 of apiready.

    • When debugOnPC is the default value false, the instance of Vue page will execute in hooks of apiready, so the debugging page cannot be previewed in PC browser.

    • When debugOnPC is true, new vue() will be executed directly to create a page instance. At this time, all api related statements cannot be executed, but the page content unrelated to api will be displayed in the browser normally.

Reference & Acknowledge