Uncaught TypeError: 无法读取未定义的属性(读取 ‘fn’)

huangapple go评论76阅读模式
英文:

Uncaught TypeError: Cannot read properties of undefined (reading 'fn')

问题

I don't understand why i keep getting this error. Please help.

*** --------------------------------------------
 * AdminLTE CardRefresh.js
 * License MIT
 * --------------------------------------------
 */

import $ from 'jquery';

/**
 * 常量
 * ====================================================
 */

const NAME = 'CardRefresh'
const DATA_KEY = 'lte.cardrefresh'
const EVENT_KEY = `.${DATA_KEY}`
const JQUERY_NO_CONFLICT = $.fn[NAME]

const EVENT_LOADED = `loaded${EVENT_KEY}`
const EVENT_OVERLAY_ADDED = `overlay.added${EVENT_KEY}`
const EVENT_OVERLAY_REMOVED = `overlay.removed${EVENT_KEY}`

const CLASS_NAME_CARD = 'card';

const SELECTOR_CARD = `.${CLASS_NAME_CARD}`
const SELECTOR_DATA_REFRESH = '[data-card-widget="card-refresh"]'
英文:

I don't understand why i keep getting this error. Please help.

*** --------------------------------------------
 * AdminLTE CardRefresh.js
 * License MIT
 * --------------------------------------------
 */

import $ from 'jquery'

/**
 * Constants
 * ====================================================
 */

const NAME = 'CardRefresh'
const DATA_KEY = 'lte.cardrefresh'
const EVENT_KEY = `.${DATA_KEY}`
const JQUERY_NO_CONFLICT = $.fn[NAME]

const EVENT_LOADED = `loaded${EVENT_KEY}`
const EVENT_OVERLAY_ADDED = `overlay.added${EVENT_KEY}`
const EVENT_OVERLAY_REMOVED = `overlay.removed${EVENT_KEY}`

const CLASS_NAME_CARD = 'card'

const SELECTOR_CARD = `.${CLASS_NAME_CARD}`
const SELECTOR_DATA_REFRESH = '[data-card-widget="card-refresh"]'

答案1

得分: 0

更新 2023:

我使用了这段代码片段来解决我遇到的所有问题!

从bootstrap 5开始,他们将要求您使用他们的Proper。而我在这里使用的是Bundle,它仍然与所有功能配合良好

对于nextjs 13

      <Script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js" />
      <Script type="text/javascript" src="https://unpkg.com/@popperjs/core@2" />
      <Script
        type="text/javascript"
        src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
        crossOrigin="anonymous"
      />
英文:

Update 2023:

I used this code snippet to fix all the problems I had!

As of bootstrap 5 they will require you to use their Proper . And here I use Bundle and it still works well with all functions

for nextjs 13

      <Script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js" />
      <Script type="text/javascript" src="https://unpkg.com/@popperjs/core@2" />
      <Script
        type="text/javascript"
        src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
        crossOrigin="anonymous"
      />

答案2

得分: -1

import * as $ from 'jquery'
英文:
import $ from 'jquery'

Looks like it's undefined. Try instead

import * as $ from 'jquery'

huangapple
  • 本文由 发表于 2023年2月7日 03:42:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75365848.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定