第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

wordpress 中的 jQuery 顯示“不能在模塊外使用導入語句”的警告

wordpress 中的 jQuery 顯示“不能在模塊外使用導入語句”的警告

PHP
胡子哥哥 2023-03-04 17:53:24
我是開發(fā) WordPress 主題的新手,但在導航菜單中遇到了一些問題。由于某些原因,我想通過 jQuery 打開子菜單,但失敗了。你們能幫我解決這個問題嗎?我在不同的 php 和 js 頁面中編寫了以下代碼。標題.php<div class="anilaDefaultHeader__bottom">    <nav class="main-menu" role="navigation" aria-label="<?php esc_html_e( 'Main Navigation', 'anila' ) ?>">                      <?php        get_template_part( 'template/header/main-menu' );        ?>    </nav>    <div class="search-area">                  <?php get_search_form(); ?>    </div></div>/src/js/navigation.jsimport $ from 'jquery';    $( '.anilaDefaultHeader__bottom' ).on( 'mouseenter', '.menu-item-has-children' (e) =>  {        $(.currentTarget).addClass('open');    }).on('mouseleave', '.menu-item-has-children', (e) => {        $(e.currentTarget).removeClass('open');    })/lib/anila-script.php    function anila_custom_script() {    wp_enqueue_style( 'style-css',get_template_directory_uri() . '/src/css/main.css' );    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {        wp_enqueue_script( 'comment-reply' );    }    wp_enqueue_script( 'anila_script', get_template_directory_uri() . '/src/js/navigation.js', array( 'jquery' ), '1.0.0', true);    include( get_template_directory() . '/lib/inline-css.php' );    wp_add_inline_style( 'style-css', $inline_styles );}add_action( 'wp_enqueue_scripts', 'anila_custom_script' );一切正常,但當我懸停時,唯一的子菜單沒有打開。如果我去檢查并手動添加“打開”類,它會正確顯示。但它應該在我懸停時打開。我去檢查和控制臺并發(fā)現錯誤**“不能在模塊外使用導入語句”**當我刪除import $ from 'jquery';來自 navigation.js然后這個消息出現在 inspect->console**$ 不是函數 navigation.js?ver=1.0.0:2**請幫助修復它。
查看完整描述

1 回答

?
一只甜甜圈

TA貢獻1836條經驗 獲得超5個贊

嘗試替換$jQuery.?這通??梢詾槲医鉀Q問題。并且不要使用import。



查看完整回答
反對 回復 2023-03-04
  • 1 回答
  • 0 關注
  • 134 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號