qidaizhe11 / vue-vuex-typescript-demo Goto Github PK
View Code? Open in Web Editor NEWVue2.5+ + Vuex + Typescript 示例
Vue2.5+ + Vuex + Typescript 示例
[ts]
无法找到模块“mint-ui”的声明文件。“g:/node/vue-vuex-typescript-demo/node_modules/mint-ui/lib/mint-ui.common.js”隐式拥有 "any" 类型。
尝试 "npm install @types/mint-ui" (如果存在),或者添加一个包含“声明模块‘mint-ui’”的新声明文件(.d.ts);
已解决!在vue-shim.d.ts中添加 declare module 'mint-ui'声明即可!
提交git自动把格式修复是用的什么插件呀
vue-cli2使用绝对路径的报错:
找不到模块“@/api/shop”。ts(2307)
10% building modules 1/1 modules 0 activeevents.js:160
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND localhost
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
think a lot,but don`t solve ,please help,thx
npm run serve 报错Cannot find module 'typescript/package.json'
克隆并安装依赖完成( cnpm i )后,
npm run dev
报警告如下:
[email protected] dev D:\Music\vue-vuex-typescript-demo
webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
10% building modules 7/10 modules 3 active ...es_webpack@3.10.0@webpack\hot\log.jsWarning: The 'await-promise' rule requires type information.
Warning: The 'no-unused-variable' rule requires type information.
Warning: The 'no-use-before-declare' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-unnecessary-qualifier' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'strict-type-predicates' rule requires type information. 95% emitting DONE Compiled successfully in 18156ms17:08:54
I Your application is running here: http://localhost:8081
启动后提示
TS2564: Property 'products' has no initializer and is not definitely assigned in the constructor.
TS2564: Property 'checkoutStatus' has no initializer and is not definitely assigned in the constructor.
TS2564: Property 'actionCheckout' has no initializer and is not definitely assigned in the constructor.
原因是 TS 2.7 默认开启 strictPropertyInitialization
添加 "strictPropertyInitialization": false
到 tsconfig.json
或者指定 TS 版本为 2.6.1
运行npm run serve后,会出现以下错误:
Error: Cannot find module 'typescript/package.json'
Error: Cannot find module 'typescript/package.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at api.chainWebpack.config (D:\git-program\vue-vuex-typescript-demo\node_modules_@[email protected]@@VUE\cli-plugin-typescript\index.js:29:23)
at webpackChainFns.forEach.fn (D:\git-program\vue-vuex-typescript-demo\node_modules_@[email protected]@@VUE\cli-service\lib\Service.js:209:40)
到底是什么问题?
我最近在重构一个以前做完的vue2.5项目,这次想使用ts。先自己创建了一个demo,但是改成ts后就报了很多错,弄了好长时间,改了一部分,但是还是不行。
这是项目地址:https://github.com/Dadaven/-1
:)
请问,在组件中使用 this.$store.getters 如何能做到自动提示和类型安全呢?我的 VSCode 好像并不能通过点运算符联想到 getters 上面的值,手写的值类型也只是 any.
运行之后
Module build failed: TypeError: Cannot set property 'tsLoaderDefinitionFileVersions' of undefined
at getEmit (/Users/denglingbo/vue-project/tsvue-demo/node_modules/_ts-loader@4.0.1@ts-loader/dist/index.js:202:61)
at successLoader (/Users/denglingbo/vue-project/tsvue-demo/node_modules/_ts-loader@4.0.1@ts-loader/dist/index.js:34:11)
at Object.loader (/Users/denglingbo/vue-project/tsvue-demo/node_modules/_ts-loader@4.0.1@ts-loader/dist/index.js:21:12)
@ multi ./node_modules/_webpack-dev-server@2.11.2@webpack-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.ts
这个报错是为什么呢?网上也搜不到。
还有就是报一个
Module build failed: TypeError: Cannot read property 'afterCompile' of undefined
at successfulTypeScriptInstance (/Users/denglingbo/vue-project/tsvue-demo/node_modules/_ts-loader@4.0.1@ts-loader/dist/instances.js:147:27)
at Object.getTypeScriptInstance (/Users/denglingbo/vue-project/tsvue-demo/node_modules/_ts-loader@4.0.1@ts-loader/dist/instances.js:48:12)
at Object.loader (/Users/denglingbo/vue-project/tsvue-demo/node_modules/_ts-loader@4.0.1@ts-loader/dist/index.js:16:41)
@ multi ./node_modules/_webpack-dev-server@2.11.2@webpack-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.ts
在网上也查不到,根据配置来的,希望得到帮助
# 图片懒加载的时候需要在main.ts引入图片
Vue.use(vueLazyload, {
loading: 'xxxx.png'
})
import './common/image/default.png'
可以引用到图片
但没法赋值。 比如说
import loadingImage from './common/image/default.png'
此时vscode就会报找不到模块
请问楼主是怎么解决这个问题的?
Vue.use(vueLazyload, {
loading: import './common/image/default.png'
})
这种方式也不行。
这个项目对我收益匪浅,感谢。初学ts,碰到很多坑。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.