Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue3 定义路由不生效 #636

Open
4 tasks done
vickllny opened this issue Oct 14, 2024 · 4 comments
Open
4 tasks done

vue3 定义路由不生效 #636

vickllny opened this issue Oct 14, 2024 · 4 comments

Comments

@vickllny
Copy link

Describe the bug

使用electron-vite创建了项目,在工程中添加vue-router路由,无论是electron子窗口或者浏览器中打开我定义的路由的地址,都是App.vue中的内容

package.json

{ "name": "electron-vite-quickstart", "version": "1.0.0", "description": "An Electron application with Vue and TypeScript", "main": "./out/main/index.js", "author": "example.com", "homepage": "https://electron-vite.org", "scripts": { "format": "prettier --write .", "lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts,.vue --fix", "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", "typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false", "typecheck": "npm run typecheck:node && npm run typecheck:web", "start": "electron-vite preview", "dev": "electron-vite dev", "build": "npm run typecheck && electron-vite build", "postinstall": "electron-builder install-app-deps", "build:unpack": "npm run build && electron-builder --dir", "build:win": "npm run build && electron-builder --win", "build:mac": "npm run build && electron-builder --mac", "build:linux": "npm run build && electron-builder --linux" }, "dependencies": { "@electron-toolkit/preload": "^3.0.0", "@electron-toolkit/utils": "^3.0.0", "vue-router": "^4.4.5" }, "devDependencies": { "@electron-toolkit/eslint-config": "^1.0.2", "@electron-toolkit/eslint-config-ts": "^2.0.0", "@electron-toolkit/tsconfig": "^1.0.1", "@rushstack/eslint-patch": "^1.10.3", "@types/node": "^20.14.8", "@vitejs/plugin-vue": "^5.0.5", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", "electron": "^31.0.2", "electron-builder": "^24.13.3", "electron-vite": "^2.3.0", "eslint": "^8.57.0", "eslint-plugin-vue": "^9.26.0", "prettier": "^3.3.2", "typescript": "^5.5.2", "vite": "^5.3.1", "vue": "^3.4.30", "vue-tsc": "^2.0.22" } }

electron.vite.config.ts

`import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()]
},
preload: {
plugins: [externalizeDepsPlugin()]
},
renderer: {
resolve: {
alias: {
'@Renderer': resolve('src/renderer/src')
}
},
plugins: [vue()]
}
})
`

/src/renderer/src/main.ts
image

/src/renderer/src/route/index.ts
image

/src/renderer/src/components/Countdown.vue
image

主进程index.ts
image

实际效果
image

Electron-Vite Version

2.3.0

Electron Version

31.0.2

Vite Version

5.3.1

Validations

@vickllny
Copy link
Author

嗯。。。 我确认已经使用的是createWebHashHistory 方法

@alex8088
Copy link
Owner

没有仔细阅读,加载方式错误

@vickllny
Copy link
Author

是这样使用的吗
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants