当前位置: 首页> 文旅> 美景 > 杭州门户网站建设公司_个人网站建设合同_91关键词排名_百度问一问人工客服怎么联系

杭州门户网站建设公司_个人网站建设合同_91关键词排名_百度问一问人工客服怎么联系

时间:2025/7/10 10:16:28来源:https://blog.csdn.net/owerm/article/details/143365641 浏览次数:0次
杭州门户网站建设公司_个人网站建设合同_91关键词排名_百度问一问人工客服怎么联系

我的vue版本是:20.17.0

一、在HTML中,引用组件格式区别

vue2引用组件可以是file.vue格式,需要导入:<script src="https://unpkg.com/http-vue-loader"></script>才可以识别vue格式。

vue3引用组件格式是:file.js。

二:vue2引用列子

1、html代码:

<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>vue2引用组件例子</title><script type="text/javascript" src="./vue2框架包/vue.js" ></script><script type="text/javascript" src="./vue2框架包/http_vue_loader.js" ></script></head><body><div id="app"><h1>Hello Vue</h1><h1>{{msg}}</h1><testvue/></div><script>var v=new Vue({el:"#app",components:{"testvue": httpVueLoader("./testvue.vue")},data:function(){return{msg:"hello"}}})</script></body>
</html>

2、vue 代码:

<template><div>欢迎您!!{{msg}}</div>
</template><script>module. Exports= {data: function(){return{msg:"child component"}}}
</script>

3、页面渲染结果:     

                   ​​​​​​​         

三、vue3引用列子

1、html代码:

<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>vue3 组件导入</title><script src="https://unpkg.com/vue@3/dist/vue.global.js"></script></head><body><div id="app"><h1>Hell Vue3</h1><h1>{{msg}}</h1><test/></div><script type="module">import test from "./testvue.js"const {createApp,ref,watch} = VuecreateApp({components:{test  //也可以:"test":test},data:function(){return{msg:"hello world"}}}).mount('#app')</script></body>
</html>

2、js代码:

const dd=`
<div>
<h1>wo shi child component</h1>
<h2>{{msg}}</h2>
</div>`export default {data: function () {return {msg: 'child component'}},template: dd
}

3、页面渲染结果:

        ​​​​​​​        ​​​​​​​        

关键字:杭州门户网站建设公司_个人网站建设合同_91关键词排名_百度问一问人工客服怎么联系

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: