javascript - 如何让单独的 html 小部件在动态页面上工作
问题描述
我正在 Wix 上建立一个加密货币网站(不要评判),并正在创建数百个动态页面来突出每种货币。我还需要在每个页面上都有一个来自 TradingView 的 html 小部件,显示每个加密货币的交易图表。例如在比特币动态页面上,有 BTC 交易图表小部件,在以太坊页面上,显示 ETH 图表等。小部件链接在这里:https ://uk.tradingview.com/widget/advanced-chart/
现在,仅供参考,我不确定 Wix 是否像其他任何地方一样构建动态页面,因为我是编码新手(因此使用 Web 构建器),但它适用于 Javscript,并且在创建动态数据集时Wix 页面的 ID 是#dynamicDataset,而 html 小部件框的 ID 是 #html1。
我在互联网上找到的最接近的帮助是通过以下链接:https ://www.wix.com/velo/forum/community-discussion/solution-html-iframes-connected-to-a-dataset-on -a-动态页面
但是,在完成所有步骤后,当我发布站点 Wix 代码 SDK 错误时收到此错误消息:传递给 src 方法的 url 参数不能设置为值。它必须是 url 类型。
这是我的代码:
$w.onReady(function () {
>to load the page before running the code
$w("#dynamicDataset").onReady(function () {
>to load the dynamic dataset's data before running the following code
$w("#html1").scrolling = "no";
>so that scroll bars, if any, do not appear on our page.
>if you want you can keep them!
let widget = $w('#dynamicDataset').getCurrentItem().widgetURL;
>we create a variable called "widget" and set its value to the URL we have
>put in our data collection.
$w("#html1").src = widget;
>we set the dynamic page's HTML element's URL value to that of "widget",
>which is actually the URL from our data collection.
})
});
我非常感谢您对此的任何帮助,并且感觉这段代码几乎是正确的?如果有人能指出我正确的方向,我将永远感激不尽。我已经搜索了 3 天,但没有运气。
控制台日志:
{"image":"wix:image://v1/da0ce5_be9fb686611249f19c63f3cb3a98ca9b~mv2.jpg/Ethereum%2 0300.jpg#originWidth=300&originHeight=300", "description": "以太坊是一个去中心化的开源区块链系统,具有以下特点:它自己的加密货币 Ether。ETH 可作为许多其他加密货币的平台,以及执行去中心化智能合约。", "_id": "00000000-0000-0000-0000-000000000002", "_owner": " da0ce518-6ee8-4595-b155-afccd4b15aa0”、“_createdDate”:“2021 年 2 月 16 日星期二 21:30:26 GMT+0000(格林威治标准时间)”、“_updatedDate”:“2021 年 2 月 20 日星期六 18:02:20 GMT +0000(格林威治标准时间)”,“smallTitle”:“以太坊(ETH)”,“graph”:“https://www.helpmebuybitcoin。com/ethereum-1", "title": "Ethereum", "link-cryptocurrencies-title": "/cryptocurrencies/ethereum", "link-cryptocurrencies-all": "/cryptocurrencies/" } ''''
解决方案
推荐阅读
- python - ctypes MessageBoxW 返回意外的中文字符
- react-native - React Native Video 在 android 上横向播放(旋转 90 度)
- java - 定序器接收器时间戳始终输出 -1
- python - 在python中为每个客户获取每个订单行之前的最后一个订单ID
- python - 类型对象“ObservableBase”没有属性“创建”RxPy
- java - 使用 lambda 和流映射列表对象
- java - 如何使用 Java 进行计时
- reactjs - 如何直接在浏览器中打开文件而不用文件名在 React 中下载
- php - 一个 Ajax 调用正在工作,但最后一个没有将数据解析到数据页
- html - 两列中带有空白区域的文本块