Comments (11)
不应该是
import HelloWorld from '@/components/HelloWorld.vue'
,为什么你这里直接import组件
没有直接import组件。项目创建完成后没有改动代码, 我粘贴的是控制台打印的错误
将 vite.config.ts 文件中的 '@/': fileURLToPath(new URL('./src/', import.meta.url))
改为 '@': fileURLToPath(new URL('./src/', import.meta.url))
就行了,难道是因为Windows系统的问题?
from create-vue.
不应该是import HelloWorld from '@/components/HelloWorld.vue'
,为什么你这里直接import组件
from create-vue.
不应该是
import HelloWorld from '@/components/HelloWorld.vue'
,为什么你这里直接import组件没有直接import组件。项目创建完成后没有改动代码, 我粘贴的是控制台打印的错误 将 vite.config.ts 文件中的
'@/': fileURLToPath(new URL('./src/', import.meta.url))
改为'@': fileURLToPath(new URL('./src/', import.meta.url))
就行了,难道是因为Windows系统的问题?
Mac os 上正常。
from create-vue.
似乎是 /
引起的。
Vite 2 之后 alias 不需要加 /
,我给忘了。
from create-vue.
似乎是
/
引起的。 Vite 2 之后 alias 不需要加/
,我给忘了。
另外使用TypeScript时,这个是不是缺少 “@types/node” 依赖
from create-vue.
是的……感谢指出
from create-vue.
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
// "@": fileURLToPath(new URL("./src", import.meta.url)),
// "@/": fileURLToPath(new URL("./src", import.meta.url)), //error
// "@": fileURLToPath(new URL("./src/", import.meta.url)),
// '@/': fileURLToPath(new URL('./src/', import.meta.url))
},
},
});
测试了这四种情况,只有第二种会报错。
@TThz-hz 你的错误能像这样再次还原吗。
from create-vue.
看一下最近的 commit,已经修复了
// "@": fileURLToPath(new URL("./src", import.meta.url)),
// "@/": fileURLToPath(new URL("./src", import.meta.url)), //error
// "@": fileURLToPath(new URL("./src/", import.meta.url)),
// '@/': fileURLToPath(new URL('./src/', import.meta.url)) //error
from create-vue.
看一下最近的 commit,已经修复了
// "@": fileURLToPath(new URL("./src", import.meta.url)), // "@/": fileURLToPath(new URL("./src", import.meta.url)), //error // "@": fileURLToPath(new URL("./src/", import.meta.url)), // '@/': fileURLToPath(new URL('./src/', import.meta.url)) //error
有点奇怪,我本地第四种是正常进入的,组件也都能加载。
from create-vue.
'@/': fileURLToPath(new URL('./src/', import.meta.url))
from create-vue.
😂 Mac OS, 看样子还和系统有关?
from create-vue.
Related Issues (20)
- git considers .vscode/ folder after new projects even if in the .girignore file HOT 1
- type-check reports errors twice HOT 2
- [plugin:vite:import-analysis] Failed to resolve import "assets/logo.svg" from "src/App.vue". Does the file exist? HOT 3
- Use Pinia in an app created with Pinia HOT 2
- How is this different from `npm create vite@latest -- --template vue`? HOT 2
- Module generates eslint config with the old commonJS syntax HOT 8
- Remove “Vue.vscode-typescript-vue-plugin” HOT 1
- Vite Plugin I Vue DevTools HOT 4
- How to set up TS configuration to use ES2021 features ? HOT 4
- regression: flags are not interpreted correctly in v3.10 when creating project HOT 2
- cannot find module using @ absolute path syntax Visual Studio Code HOT 5
- Add ESLint run-on-save VSCode settings HOT 3
- create vue project error . TypeError: (0 , import_node_util.parseArgs) is not a function HOT 5
- vue template script buggy HOT 2
- TS2307: Cannot find module '@/components/echarts' or its corresponding type declarations. HOT 8
- Add Issue templates HOT 1
- Add PR template HOT 1
- Cannot find base config file "@vue/tsconfig/tsconfig.dom.json" [tsconfig.json] HOT 14
- The e2e tests in the subfolders under e2e/ are being executed by vitest
- ESLint v9 support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from create-vue.