用html框架插入一个图片生成vue3生成vue3格式 script setup代码要求所有方法或箭头函数都用function定义要求所有变量为ref响应式无需任何文字说明只要源码即可
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue 3 Image Demo</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="app">
<img :src="imageSrc" alt="Vue 3 Image">
</div>
<script>
const App = {
setup() {
const imageSrc = Vue.ref('https://via.placeholder.com/350x150')
return {
imageSrc
}
}
}
Vue.createApp(App).mount('#app')
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/bcvZ 著作权归作者所有。请勿转载和采集!