在传统HTML页面中Vue3使用CDN方式 该如何 引入并使用组件呢?
index.html
const { createApp, ref, reactive } = Vue;
//导入
import test from "/路径/mytest.js";
//注册
app.component('testa', test);定义子组件 mytest.js
const { createApp, ref, reactive, nextTick, onMounted, onUpdated, onBeforeUnmount, toRefs } = Vue;
export default {
emits: ['clicked'],
props: ['title'],
setup(props, context) {
const count = ref(0);
console.log('props', props.title);
const clickComponent = () => {
context.emit('clicked');
}
return { count, clickComponent }
},
template: `组件 mytest`
}子组件与父组件的参数/方法传递自行研究测试看看吧