vue.js不通过webpack/npm/yarn加载单文件组建
可以用此插件:https://github.com/FranckFreiburger/http-vue-loader
<script src="https://cdn.jsdelivr.net/npm//src/httpVueLoader.min.js"></script> Vue.component(‘block-header‘, httpVueLoader(‘/block-header.vue‘))
这样就能在页面上通过http的方式加载.vue单文件组件了。
如果只是加载html模板的话可以这样(不能包含<style>和<script>):
Vue.component(‘block-menu‘, function (resolve, reject) { axios.get(`/block-menu.html`).then(resp => resolve({template: resp.data})) })
相关推荐
hline 2020-07-29
yegen00 2020-10-21
Notzuonotdied 2020-09-17
tomli 2020-07-26
xieting 2020-07-04
YarnSup 2020-06-28
flyingbird 2020-06-14
Notzuonotdied 2020-06-13
xieting 2020-05-29
tomli 2020-05-27
xieting 2020-05-26
tomli 2020-05-25
tomli 2020-05-11