Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用UMD方式引入,代码出不来,控制台报错:require is not defined #628

Open
kagol opened this issue Dec 28, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@kagol
Copy link

kagol commented Dec 28, 2024

Describe the bug

完全拷贝以下文档中 UMD 方式使用的代码:

https://github.com/petercat-ai/petercat/blob/main/docs/guides/quick_%20assistant_start_cn.md

先引入以下代码:

<head>
  <script src="https://cdn.jsdelivr.net/npm/react/umd/react.development.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/react-dom/umd/react-dom.development.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/dayjs/dayjs.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/antd/dist/antd.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/lottie-web/build/player/lottie.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/@petercatai/[email protected]/dist/umd/assistant.min.js"></script>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@petercatai/[email protected]/dist/umd/assistant.min.css">
</head>

再引入以下代码:

<body>
  ...
   <script>
     PetercatLUI.initAssistant({
       apiDomain: 'https://api.petercat.ai',
       token: 'your-token',
       starters: ['介绍下这个项目', '查看贡献指南', '我该怎样快速上手'],
       clearMessage: true
     });
  </script>
</body>

代码显示不出来,控制台报错:

image

To Reproduce

复现链接:https://opentiny.github.io/tiny-vue/

提问输入框中问以下问题:怎么使用tree-menu组件,给出示例代码

即可复现。

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@kagol kagol added the bug Something isn't working label Dec 28, 2024
@xingwanying xingwanying reopened this Dec 30, 2024
@xingwanying
Copy link
Contributor

@kagol 使用新版本还有这个问题么?

<script src="https://cdn.jsdelivr.net/npm/react/umd/react.development.js"></script> <script src="https://cdn.jsdelivr.net/npm/react-dom/umd/react-dom.development.js"></script> <script src="https://cdn.jsdelivr.net/npm/dayjs/dayjs.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/antd/dist/antd.js"></script> <script src="https://cdn.jsdelivr.net/npm/lottie-web/build/player/lottie.js"></script> <script src="https://cdn.jsdelivr.net/npm/@petercatai/assistant@latest/dist/umd/assistant.min.js"></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants