位置:- 正文

html文件里怎么引用vue组件?(html文档怎么写)

编辑:rootadmin
html文件里怎么引用vue组件?

推荐整理分享html文件里怎么引用vue组件?(html文档怎么写),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:html怎么样,html文件放在哪里,html文件怎么放进文件夹,html怎样,html文件怎么放进文件夹,文件html怎么能导入word文档里,html文件怎么弄,html文件怎么弄,内容如对您有帮助,希望把文章链接给更多的朋友!

这里我们使用 http-vue-loader 来实现:https://www.npmjs.com/package/http-vue-loader

html文件里怎么引用vue组件?(html文档怎么写)

Load .vue files directly from your html/js. No node.js environment, no build step.

我做了个demo如下:

html文件里面写下面的代码

<!DOCTYPE html><html> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>测试页面</title> <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> <script src="https://unpkg.com/http-vue-loader"></script> </head> <body> <div id="app"> <kaimo-info></kaimo-info> </div> <script> new Vue({ el: "#app", data: function () { return { }; }, components: { 'kaimo-info': httpVueLoader('./component/KaimoInfo.vue'), }, methods: { }, }); </script> </body></html>

KaimoInfo.vue 组件里写下面的代码,注意使用的是 module.exports

<template> <div class='kaimo-info'> {{msg}} </div></template><script>module.exports = { name: 'KaimoInfo', data () { return { msg: "hello http-vue-loader --- kaimo " }; }, created() { }, mounted() { }, methods: { },};</script><style scoped></style>

效果如下:

本文链接地址:https://www.jiuchutong.com/zhishi/284018.html 转载请保留说明!
下一篇链接:https://www.jiuchutong.com/zhishi/284019.html
免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络