Went with the runtime-only
build version of Vue.js for a new project. I saw in the docs that to switch to the standalone
one needs to add an alias to webpack, like so:
resolve: {
alias: {
'vue$': 'vue/dist/vue.js'
}
}
At the moment, I don't need the piler in my app. However, it's possible that at some point I will need to switch to the standalone
build.
My question is:
Will it be a painless switch between runtime-only
and standalone
later or will it require heavy refactoring?
If it does, I might as well start with standalone
and avoid refactoring later on.
Went with the runtime-only
build version of Vue.js for a new project. I saw in the docs that to switch to the standalone
one needs to add an alias to webpack, like so:
resolve: {
alias: {
'vue$': 'vue/dist/vue.js'
}
}
At the moment, I don't need the piler in my app. However, it's possible that at some point I will need to switch to the standalone
build.
My question is:
Will it be a painless switch between runtime-only
and standalone
later or will it require heavy refactoring?
If it does, I might as well start with standalone
and avoid refactoring later on.
1 Answer
Reset to default 9standalone
supports template option in ponents. For example, you can do this:
Vue.ponent('my-ponent', {
template: '<div>A custom ponent!</div>'
})
standalone
also allows you to load vue.js
from a CDN, like you would do with jQuery or any other javascript library.
runtime-only
does not allow you to use template
in ponent definition. So you need to create my-ponent.vue
file and define template inside as detailed in Single File Components guide: http://vuejs/guide/single-file-ponents.html
Also you need to use vue-cli
for development, if you are using runtime-only
.
To switch from standalone
to runtime-only
, you will have to rewrite all the ponents into my-ponent.vue
files, and start using vue-cli
To switch from runtime-only
to standalone
, there are no changes required.
Other than that, it is painless to switch between runtime-only
and standalone
.
My preference: runtime-only
only mode, as it produces much smaller builds and theoretically performs better, as templates are pre-piled. Also the sections in vue
file are well organized and easy to read. Separate vue files for ponents also forces you to structure your app better.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744273644a4566224.html
评论列表(0条)