gpt4 book ai didi

javascript - 如何使用 requirejs 连接 jquery.inputmask

转载 作者:可可西里 更新时间:2023-11-01 01:53:35 27 4
gpt4 key购买 nike

如何正确连接https://github.com/RobinHerbots/jquery.inputmask使用 requirejs?官方网站文档中的方法不正确。

我试着把它变成这样

require-config.js

paths: {
...
inputmask: "/assets/vendor/jquery.inputmask/dist/inputmask/inputmask",
dependencyLib: "/assets/vendor/jquery.inputmask/dist/inputmask/dependencyLib",
jQueryInputmask: "/assets/vendor/jquery.inputmask/dist/inputmask/jquery.inputmask",
...
}

脚本.js

define('script', ['jquery', 'jQueryInputmask'], function ($) {
...
$obj.inputmask(
{
alias: 'currency',
rightAlign: false,
digits: 0
}
);
...
});

但是没用

最佳答案

试试这个代码:

require.config({
paths: {
...
"jquery" : "../dist/jquery/jquery",
"jQueryInputmask" : "../dist/inputmask/jquery.inputmask",
"inputmask" : "../dist/inputmask/inputmask",
...
},
shim: {
jquery: {
exports: "$"
},
jQueryInputmask: {
deps: ["jquery", "inputmask"],
exports: "$"
},
)

define('script', ['jquery', 'jQueryInputmask'], function ($) {
...
$obj.inputmask(
{
alias: 'currency',
rightAlign: false,
digits: 0
}
);
...
});

在我的项目中,它可以设置垫片:

shim: Configure the dependencies, exports, and custom initialization for older, traditional "browser globals" scripts that do not use define() to declare the dependencies and set a module value.

关于javascript - 如何使用 requirejs 连接 jquery.inputmask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32980824/

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