http-vue-loader
直接从html / js加载.vue文件。没有node.js环境,没有构建步骤。
示例
这是一个vue文件:my-component.vue
<template>
<div class="hello">Hello {{who}}</div>
</template>
<script>
module.exports = {
data: function() {
return {
who: 'world'
}
}
}
</script>
<style>
.hello {
background-color: #ffe;
}
</style>
利用http-vue-loader插件,在index.html
文件中使用my-component.vue
文件
<!doctype html>
<html lang="en">
<head>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/http-vue-loader"></script>
</head>
<body>
<div id="my-app">
<my-component></my-component>
</div>
<script type="text/javascript">
new Vue({
el: '#my-app',
components: {
'my-component': httpVueLoader('my-component.vue')//加载需要使用的vue文件
}
});
</script>
</body>
</html>