formvalidation v1.3.0 不适用于 requirejs

Posted

技术标签:

【中文标题】formvalidation v1.3.0 不适用于 requirejs【英文标题】:formvalidation v1.3.0 not working with requirejs 【发布时间】:2019-07-15 23:53:36 【问题描述】:

我有以下代码,目前是 WORKING 代码

表格:

<form id="demoForm" method="POST">
    // bootstrap form...
</form>

页面脚本:

<script src="~/scripts/Framework/jquery-3.3.1.min.js"></script>
<script src="~/scripts/Framework/bootstrap-4/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.min.js"></script>
<script src="~/scripts/Plugins/formvalidation-1.3.0/js/FormValidation.full.min.js"></script>
<script src="~/script/Plugins/formvalidation-1.3.0/js/plugins/Bootstrap.min.js"></script>
 <script src="~/script/Plugins/formvalidation-1.3.0/js/plugins/J.min.js"></script>
<script>
$(function()
$('#demoFrom').formValidation(
plugins: 
declarative: new FormValidation.plugins.Declarative( html5Input: true ),
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap(),
submitButton: new FormValidation.plugins.SubmitButton(),
icon: new FormValidation.plugins.Icon(
    valid: 'fa fa-check',
    invalid: 'fa fa-times',
    validating: 'fa fa-refresh'
)

);
);
</script>

但是当我尝试使用 requirejs 时,它不是。下面的 NOT WORKING 代码:

<script src="~/scripts/Framework/require.js" data-main="~/scripts/app.js">

App.js:

require.config(
    baseUrl: '/Scripts/',
    paths: 
        jquery: 'Framework/jquery-3.3.1.min',
        bootstrap:'Framework/bootstrap-4/js/bootstrap.bundle.min',
        es6Shim: 'Framework/es6-shim.min',
        fvMain: 'Plugins/formvalidation-1.3.0/js/FormValidation.full.min',
        fvBootstrap: 'Plugins/formvalidation-1.3.0/js/plugins/Bootstrap.min',
        fvJQuery: 'Plugins/formvalidation-1.3.0/js/plugins/J.min'
    ,
    shim: 
        jquery: 
            exports: '$'
        ,
        bootstrap: 
            deps:['jquery']
        ,
        fvBootstrap: 
            deps: ['es6Shim', 'fvMain','fvJQuery']
        
    
);

require(['jquery', 'bootstrap'],
    function ($) 
//... some other tasks
require[('fvBootstrap'), function()
$('#demoFrom').formValidation(
plugins: 
declarative: new FormValidation.plugins.Declarative( html5Input: true ),
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap(),
submitButton: new FormValidation.plugins.SubmitButton(),
icon: new FormValidation.plugins.Icon(
    valid: 'fa fa-check',
    invalid: 'fa fa-times',
    validating: 'fa fa-refresh'
)

);
);

);

在 requirejs 代码中我收到错误“FormValidation is not defined”

我已尝试联系开发人员解决此问题,但没有成功。任何人都可以帮助我吗?

【问题讨论】:

【参考方案1】:

再次检查你的导入,我猜你包含了这个库,但实际上你的目录中没有它。 检查这个导入

<script src="~/scripts/Plugins/formvalidation-1.3.0/js/FormValidation.full.min.js"></script>

【讨论】:

以上是关于formvalidation v1.3.0 不适用于 requirejs的主要内容,如果未能解决你的问题,请参考以下文章

SonarQube社区版分支插件V1.3.0更新

云原生动态周报 | Volcano社区正式发布v1.3.0版本

mAPI软件发布升级版本v1.3.0(测试版)

投稿系统 v1.3.0 菜单快捷搜索 模块市场升级

mAPI软件发布升级版本v1.3.0(正式版)

快应用开发工具升级v1.3.0