我的任务是创建一个具有vue3类型支持的应用程序,我还必须使用vuex进行状态管理,使用vue-路由器进行基本路由。但我不能在这个项目中使用vue-cli
我现在的代码是:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://unpkg.com/vue@next"></script>
<script src="https://unpkg.com/vue-router@4"></script>
<script src="https://unpkg.com/vuex@3.6.2/dist/vuex.js"></script>
</head>因为我从来没有在vue项目中使用过打字本
,你能向我推荐一些博客,教程,当有人用这些工具从零开始构建一个vue3应用程序,但没有vue-cli?。
全额收费:
在VueJS 3.0框架上编写登录表单并使用TypeScript。您还应该使用Vuex ()存储和操作数据,例如从服务器记录、读取和检索数据。@ Vue / cli不应在项目中使用。在这个项目中,你必须亲自管理webpack。
这对我来说很重要。
提前感谢
发布于 2021-05-17 14:59:46
如果不能使用Vue CLI,则必须手动安装依赖项。
为了保持简单,您可以使用Parcel作为绑定器。
这样你就不用处理配置webpack的问题了。
首先要确保在全球范围内安装了类型记录。
接下来,按照以下方式配置package.json:
{
"name": "project name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC",
"scripts": {
"clean": "rm dist/bundle.js",
"start": "parcel src/index.html",
"build-prod": "parcel build src/index.html"
},
"dependencies": {
"vue@next": "^2.6.12",
"vuex": "2.0.0",
"vue-router": "2.0.0"
},
"devDependencies": {
"parcel-bundler": "^1.12.5"
}
}这包括Vue3、Vuex、Vue路由器和parcel的依赖关系以及一些包的安装脚本。
执行yarn install或npm install来安装所有依赖项。
接下来,确保根目录下有一个App.vue、index.html和index.ts。
最后,在根目录下创建以下文件:
vue.shim.d.ts
declare module "*.vue" {
import Vue from 'vue'
export default Vue
}tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"strict": true,
"noImplicitReturns": true,
"noImplicitAny": true,
"module": "es6",
"moduleResolution": "node",
"target": "es5",
"allowJs": true,
},
"include": [
"./src/**/*"
]
}看看这个很棒的网站:https://createapp.dev/parcel
它允许您在没有Vue CLI的情况下配置构建,并实现所需的特性。
您可以生成一个带有Vue和类型记录的项目,下载它,然后根据需要添加Vue路由器和Vuex。
https://stackoverflow.com/questions/67571528
复制相似问题