小编Kiy*_*ynL的帖子

vue3+vite+vuei18n 构建“未捕获的类型错误:_ctx.$t 不是函数”

我想将我的 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)

vue.js vue-i18n vite

5
推荐指数
1
解决办法
8133
查看次数

如何获得没有父母的所有孩子?

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)

c# unity-game-engine

4
推荐指数
1
解决办法
4646
查看次数

如何在 C# 中定义异步操作?

我真的想知道是否有办法定义动作变量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)

c# delegates action asynchronous async-await

3
推荐指数
1
解决办法
447
查看次数