ReferenceError: _ is not defined

前端 未结 3 2034
粉色の甜心
粉色の甜心 2020-12-14 15:04

I am using a jQuery based WordPress Twitter widget and receive the error \"ReferenceError: _ is not defined\".

Am not sure how to declare the variable \

相关标签:
3条回答
  • 2020-12-14 15:09

    i was facing the same problem in the wp-admin section of the site. I enqueued the underscore script cdn and it fixed the problem.

    function kk_admin_scripts() {
        wp_enqueue_script('underscore', '//cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.min.js' );
    }
    add_action( 'admin_enqueue_scripts', 'kk_admin_scripts' );
    
    0 讨论(0)
  • 2020-12-14 15:14

    You can install it by bower:

    Node.js npm install underscore
    Meteor.js meteor add underscore
    Require.js require(["underscore"], ...
    Bower bower install underscore
    Component component install jashkenas/underscore
    

    Here's the link to the oficial page http://underscorejs.org/

    0 讨论(0)
  • 2020-12-14 15:26

    Your widget has Underscore.js/LoDash.js as dependency.

    You can get them here: underscore, lodash

    Try prepending this to your code, so you can see if it works:

    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.min.js"></script>
    
    0 讨论(0)
提交回复
热议问题