? Project name (vue-webpack-demo) ? Project description (A Vue.js project) ? Author (chris <dwatow@gmail.com>) ? Vue build (Use arrow keys) ❯ Runtime + Compiler: recommended for most users Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere
? Install vue-router? (Y/n) ? Use ESLint to lint your code? (Y/n) ? Pick an ESLint preset (Use arrow keys) ❯ Standard (https://github.com/standard/standard) Airbnb (https://github.com/airbnb/javascript) none (configure it yourself)
? Set up unit tests (Y/n) ❯ Jest Karma and Mocha none (configure it yourself)
? Setup e2e tests with Nightwatch? (Y/n) ? Should we run \`npm install\` for you after the project has been created? (recommended) (Use arrow keys) ❯ Yes, use NPM Yes, use Yarn No, I will handle that myself ## 到此就是所有的問題了
+ // The Vue build version to load with the `import` command + // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
//...
new Vue({ el: '#app', router, - render: h => h(App) + components: { App }, + template: '<App/>' })
Vue build 選 2: Runtime-only: about 6KB lighter min+gzip,
but templates (or any Vue-specific HTML) are
ONLY allowed in .vue files - render functions are
required elsewhere
意思是使用更接近編譯器的模版替代方案: 使用自訂的渲染函數來初始 vue 的 root
1 2 3 4 5 6
render: function (createElement) { return createElement( 'h' \+ this.level, // tag name: h1~h6 this.$slots.default // array of children ) },
A full-featured Browserify + vueify setup with hot-reload, linting & unit testing.
A full-featured Browserify
vueify setup with hot-reload
linting
unit testing.
使用 browserify 的選項
$ vue init browserify vue-browserify-demo
A newer version of vue-cli is available.
latest: 2.9.3 installed: 2.9.2
? Project name vue-browserify-demo ? The version of the package 0.1.0 ? Project description A Vue.js project ? Author chris <dwatow@gmail.com> ? Vue build standalone ? Use ESLint to lint your code? Yes ? Setup unit tests with Karma + Jasmine? Yes
vue-cli · Generated "vue-browserify-demo".
To get started:
cd vue-browserify-demo npm install npm run dev
初始化完成後,輸入下列指令,可看見初始化好的成果
$cd vue-browserify-demo $ npm install $ npm run dev
PWA template for vue-cli based on the webpack template
用 Vue 寫 PWA。
$ vue init pwa my-project
A newer version of vue-cli is available.
latest: 2.9.3 installed: 2.9.2
? Project name vue-pwa-demo ? Project short name: fewer than 12 characters to not be truncated on homescreens (default: same as name) ? Project description A Vue.js project ? Author chris <dwatow@gmail.com> ? Vue build standalone ? Install vue-router? Yes ? Use ESLint to lint your code? Yes ? Pick an ESLint preset Standard ? Setup unit tests with Karma + Mocha? Yes ? Setup e2e tests with Nightwatch? Yes
vue-cli · Generated "vue-pwa-demo".
To get started:
cd vue-pwa-demo npm install npm run dev
Documentation can be found at https://vuejs-templates.github.io/webpack