const cac = require('cac');
const cli = cac.cac('lininn-theme');
cli.command('', '生成样式文件')
.option('-p, --platform <platform>', '配置平台')
.option('--prefix <prefix>', '配置前缀')
.option('--font <font>', '配置字体大小:normal|large|small,默认 normal')
.option...阅读全文>>
阅读全文>>
Step 1️:创建一个 Store Model
// ./src/stores/todo.ts
import { action, observable, computed } from 'mobx';
export interface ITodo {
id: number;
name: string;
desc: string;
done?: boolean;
}
let id = 0;
export class TodoStore {
@observable todos: ITodo[] = [];
// 利用计算属性计算完成个未完成个数
@compu...阅读全文>>
settings.json:
"eslint.options": {
"overrideConfig": {
"env": {
"browser": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"no-debugger": "off"
}
}
},阅读全文>>
export default defineConfig({
cssLoader: {
modules: {
auto: true,
},
},
})阅读全文>>
window.location.replace
1
window.location.replace('要转向的页面') //不会有历史记录
1 2 3 4
let backLen = history.length history.forward() history.go(-backLen) // Return at the beginning window.location.replace('/#/home')
...阅读全文>>
原本打包过后是css-in-js,配置完MiniCssExtractPlugin后,可以将css单独打包出来
配置
1,安装npm install --save-dev mini-css-extract-plugin
2,将style-loader替换成MiniCssExtractPlugin.loader (style.loader,支持HMR,但MiniCssExtractPlugin目前正在支持(还没))
3,安装npm install --save-dev optimize-css-assets-webpack-...阅读全文>>
优先通过修改源代码来解决;修改后记得重启,有的依赖需重新处理
其次通过预构建或 CommonJS 插件处理;
为了解决这一问题,我对搜索到的数个 CommonJS 插件进行简单地试用,最终基于成熟、可靠、全面等几方面的考虑,采用 @rollup/plugin-commonjs 。
import commonjs from '@rollup/plugin-commonjs';
export default defineConfig({
plugins: [
commonjs...阅读全文>>
Hi you are using Webpack 4 and Terser ^5.0.0. This version of Terser is for Webpack 5, you need to set version "terser-webpack-plugin": "^4.2.3", in package.json file
您正在使用Webpack 4和精简版^5.0.0。此版本的Terser适用于网页包5,您需要在软件包中设置版本“terser webpack plugin”:“^4.2.3”json文件阅读全文>>
interface IRecipeProps {
ingredients?: string[];
title?: string;
img?: string;
instructions?: string;
}
interface IRecipeState {
}
class Recipe extends Component<IRecipeProps, IRecipeState>&n...阅读全文>>