This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.
Since TypeScript cannot handle type information for .vue imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in .vue imports (for example to get props validation when using manual h(...) calls), you can enable Volar's Take Over mode by following these steps:
- Run
Extensions: Show Built-in Extensionsfrom VS Code's command palette, look forTypeScript and JavaScript Language Features, then right click and selectDisable (Workspace). By default, Take Over mode will enable itself if the default TypeScript extension is disabled. - Reload the VS Code window by running
Developer: Reload Windowfrom the command palette.
You can learn more about Take Over mode here.
pnpm install
pnpm -F <package_selector> pnpm -F sc-twin add loadsh
pnpm -F sc-twin dev
@use "@runafe/sc-style" as ; 使用 as,那么这一模块就处于全局命名空间。
corners.scss
$radius: 3px;
@mixin rounded {
border-radius: $radius;
}
index.scss
@use "src/corners" as *;
.button {
@include rounded;
padding: 5px + $radius;
}
正确
通过vite 提供import.meta.url 加载器加载地址
const url = new URL('../assets/venice_sunset_1k.hdr', import.meta.url).href
scene.environment = new RGBELoader().load(url, () => {})
错误
scene.environment = new RGBELoader().load('../assets/venice_sunset_1k.hdr', () => {}) 文件引入404
问题:packageA 加载packageB 局部安装过程中出现包找不到情况 方法:将所以包 装在根目录下
问题:
type": "module" which defines all .js files in that package scope as ES modules.
Instead rename .eslintrc.js to end in .cjs, change the requiring code to use import(), or remove "type": "module"
原因: 设置package.json type": "module" 模块化方案为esm 不支持支持commonjs
方法:
需设置文件后缀为cjs 或者 删除 "type": "module"配置
$ pnpm -F admin exec eslint . --fix 格式化文件