- 路径替换.
npm install --save-dev @types/node
import { resolve } from 'path'
const pathResolve = (dir: string): any => {
return resolve(__dirname, ".", dir)
}
const alias: Record<string, string> = {
'@': pathResolve('src')
}
export default defineConfig({
plugins: [
vue()
],
resolve: {
alias
}
})
- ts报错:Cannot find module '@/router' or its corresponding type declarations.ts(2307)
resolution:
declare module '*.type' {
import { DefineComponent } from "vue"
const component: DefineComponent<{}, {}, any>
export default component
}
这个办法没什么用,对于{module} 导出会有ts2614的报错, 最后把vetur插件disable掉换成volar实现正常
- 安装jquery
import inject from "@rollup/plugin-inject"
plugins: [
vue(),
inject({
$: "jquery", // 这里会自动载入 node_modules 中的 jquery jquery全局变量
jQuery: "jquery",
"windows.jQuery": "jquery"
})
],
@for $i from 1 through 30 {
.p-#{$i} {
padding: #{$i}+'px';
}
}
-
optimize
-
Property 'replaceAll' does not exist on type 'string'. Do you need to change your target library?
- px2rem+zoom 实现自适应
因为zoom属性的non-standard,所以在编译时会报错,改成
即可