我想将我的 vue3+vite 包发布到 npm,但发布后,我在测试项目中遇到“Uncaught TypeError: _ctx.$t is not a function”,并且我的包无法工作,有什么建议吗...?
PS:我正在使用 vue options api
vite.configs.js:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueI18n from '@intlify/vite-plugin-vue-i18n'
// https://vitejs.dev/config/
const path = require("path")
export default defineConfig({
build: {
lib: {
entry: path.resolve(__dirname, 'src/install.ts'),
name: 'vcp',
fileName: (format) => `vcp.${format}.ts`
},
rollupOptions: {
external: ['vue'],
output: {
exports: 'named',
globals: {
vue: 'Vue',
vcp: 'Vcp'
}
}
},
},
plugins: [
vue(),
vueI18n({
include: path.resolve(__dirname, 'src/assets/translations.json'),
compositionOnly: false,
}) …Run Code Online (Sandbox Code Playgroud) Transform[] drawns = GetComponentsInChildren<Transform>()
Run Code Online (Sandbox Code Playgroud)
这还包括父级,但我只想获取脚本所连接的转换的子级。
问题是它在循环中也破坏了父级。绘制数组中的第一项是父项:
case DrawStates.DrawOnGizmosRuntime:
drawOnce = true;
if (line != null && drawOnGizmos == false)
{
Transform[] drawns = GetComponentsInChildren<Transform>();
if (drawns.Length > 0)
{
foreach (Transform drawn in drawns)
{
Destroy(drawn.gameObject);
}
}
}
if (boxCollider == null)
{
boxCollider = boxColliderToDrawOn.GetComponent<BoxCollider>();
}
drawOnGizmos = true;
break;
Run Code Online (Sandbox Code Playgroud) 我真的想知道是否有办法定义动作变量async?或者一些替代方法?
public System.Action myAction;
public async System.Action myAsyncAction;
void Start()
{
// normal action
myAction += () =>
{
Debug.Log("Inject some code in runtime..");
};
// I want something like this that support wait time..
myAsyncAction += () =>
{
await Task.Delay(2000f);
Debug.Log("Inject some code in runtime..");
};
}
Run Code Online (Sandbox Code Playgroud)