<!DOCTYPE html> <html lang="en"> <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>Document</title> </head> <body> <div id="app"> <h1>{{data.name}}</h1> <img src="../static/img/sea.jpg" alt="" /> </div> </body> </html> <script src="https://cdn.jsdelivr.net/npm/vue@3.0.11/dist/vue.global.prod.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> <script src="https://cdn.bootcss.com/qs/6.7.0/qs.min.js"></script> <script> const { createApp, reactive, getCurrentInstance } = Vue; const app = createApp({ setup() { const data = reactive({ name: "aa", }); getInformation(); //方法1 function getInformation() { //方法的实现 data.name = "引入的html文件"; } // 方法2 const handleClick = (val) => { //方法的实现 }; return { data, handleClick, }; }, }); app.mount("#app"); </script>