gpt4 book ai didi

javascript - 如何导入Jquery RateYo?

转载 作者:行者123 更新时间:2023-12-01 01:53:26 25 4
gpt4 key购买 nike

我正在尝试将 Jquery Rateyo 导入到我的项目中,但似乎不起作用。这是代码

import $ from "jquery";
import rateYo from "rateyo";

class Rating {
constructor() {
$(function() {
$("#rateYo").rateYo({
rating: 1.5,
starWidth: "40px",
numStars: 5,
halfStar: true
});
});
}
}

export default Rating;

我也在使用 webpack。

它不会显示在用户界面中。并且还会生成一个错误,指出:

jquery.js?1157:3841 jQuery.Deferred exception: jquery__WEBPACK_IMPORTED_MODULE_0___default(...)(...).rateYo is not a function TypeError: jquery__WEBPACK_IMPORTED_MODULE_0___default(...)(...).rateYo is not a function at HTMLDocument.eval (webpack-internal:///./js/modules/Rating.js:12:64) at mightThrow (webpack-internal:///./node_modules/jquery/dist/jquery.js:3557:29) at process (webpack-internal:///./node_modules/jquery/dist/jquery.js:3625:12) undefined

最佳答案

您需要使用jquery版本的模块@rateyo/jquery

您可以执行以下操作。

import $ from "jquery";
import "@rateyo/jquery";

$("#rateyo").rateYo();

顺便说一句,rateyo 期望 jquery >= 3.0.0

关于javascript - 如何导入Jquery RateYo?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60397621/

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