gpt4 book ai didi

javascript - react native : How to add script tag in the component

转载 作者:行者123 更新时间:2023-11-29 23:19:50 26 4
gpt4 key购买 nike

我正在尝试在 React Native 应用程序的组件内添加标签。下面是我的代码,它似乎不起作用。谁能告诉我如何解决这个问题?

import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Dimensions from 'Dimensions';
import {StyleSheet, View, TextInput, Image, Text} from 'react-native';

export default class Chatbot extends Component {
render() {
return (
<View>
<Text>Testing</Text>

<script type="text/javascript">
window.__be = window.__be || {};
window.__be.id = "5b3a47b4b30a36000769d821";
(function() {
var be = document.createElement('script'); be.type = 'text/javascript'; be.async = true;
be.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.botengine.ai/widget/plugin.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(be, s);
})();
</script>

</View>
);
}
}

最佳答案

我的猜测是您编写的代码不会在浏览器中运行。脚本标签用于告诉浏览器:“嘿浏览器,停止。我们这里有一些 javascript。执行它”,所以你应该忘记脚本标签。

关于javascript - react native : How to add script tag in the component,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51139829/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com