小编Xin*_*Lee的帖子

我如何在 Next.js 中使用我的 jquery 插件?

我正在使用 Next.js 开发 Web 应用程序,我想在 Next.js 中使用 jQuery。但我无法导入 jquery 插件。请检查我的代码并帮助我。


import React from 'react';
import Document, { Head, Main, NextScript } from 'next/document';
import { ServerStyleSheet } from 'styled-components';

export default class MyDocument extends Document {
  static getInitialProps({ renderPage }) {
    const sheet = new ServerStyleSheet();
    const page = renderPage(App => props => sheet.collectStyles(<App {...props} />));
    const styleTags = sheet.getStyleElement();
    return { ...page, styleTags };
  }

  render() {
    return (
      <html lang="en">
        <Head>{this.props.styleTags}
          <link
            href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0/katex.min.css"
            rel="stylesheet"
          />
         <script src="../static/js/jquery.main.js" async/> …
Run Code Online (Sandbox Code Playgroud)

import jquery-plugins hyperlink reload next.js

3
推荐指数
1
解决办法
6809
查看次数

标签 统计

hyperlink ×1

import ×1

jquery-plugins ×1

next.js ×1

reload ×1