react-activation icon indicating copy to clipboard operation
react-activation copied to clipboard

请问在vite里面能使用吗

Open SuperMrBean opened this issue 3 years ago • 3 comments

想在vite里面使用,请问需要怎么配置呢

SuperMrBean avatar Feb 25 '22 07:02 SuperMrBean

1. 添加 vite babel 插件(可选项、建议)

import { defineConfig } from 'vite'
import reactNodeKey from 'react-node-key/vite';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    reactNodeKey()
  ]
})

2. 业务代码中用 es moudle 引入相关组件

import { AliveScope, KeepAlive } from 'react-activation'

CJY0208 avatar Mar 01 '22 01:03 CJY0208

1. 添加 vite babel 插件(可选项、建议)

import { defineConfig } from 'vite'
import reactNodeKey from 'react-node-key/vite';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    reactNodeKey()
  ]
})

2. 业务代码中用 es moudle 引入相关组件

import { AliveScope, KeepAlive } from 'react-activation'

这个包是不是最新的没有发布 我安装完看没有 vite 目录

jiachenyu1 avatar Mar 21 '22 05:03 jiachenyu1

试试 v0.3.2,补发了一个,之前确实漏掉了 vite 目录

CJY0208 avatar Mar 22 '22 02:03 CJY0208

除了配置 vite plugins,还可以选择手动标记 KeepAlive 的 cacheKey 属性,参考此处

CJY0208 avatar Sep 21 '22 04:09 CJY0208