[plugin:vite:vue] At least one <template> or <script> is required in a single file component.
![1***@163.com](https://img-cdn-tc.dcloud.net.cn/account/identicon/02b4c153d0b29c479eed389f4c8975d5.png)
- 发布:2023-03-18 01:18
- 更新:2024-09-14 21:59
- 阅读:6995
[plugin:vite:vue] At least one <template> or <script> is required in a single file component.
![f***@163.com](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/002/41/22/83_avatar_mid.jpg?v=1692254176)
使用Vue3 TS来编写uniapp的项目。编译时出现'At least one <template> or <script> is required in a single file component.'
![l***@163.com](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/002/57/54/03_avatar_mid.jpg?v=1728963219)
l***@163.com - 路飞君
解决方法:
必须在返回对象的时候包含{
plugins: [uni()],
...你的配置
}
产生原因:
//必须要plugins: [uni()],,官方要求,不然他会告诉你需要需要引入@vitejs/plugin-vue ,错误信息是port analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle .vue files.
当你这样引入并使用的时候就会出现
[plugin:vite:vue] At least one <template> or <script> is required in a single file component.
1***@qq.com
同样的问题,注释掉vue()就好了,感谢
2023-12-25 09:42