将Foundation和jQuery导入nextjs Web应用程序

问题描述 投票:0回答:1

[我试图将Zurb Foundation的脚本导入到我的下一个js应用程序中,但只有在包含Foundation core时收到以下错误...

/ Users / alasdair_macrae / Sites / merlin / spa_runescape / node_modules / foundation-sites / js / foundation.core.js:3

从'jquery'导入$;

^^^^^^^

SyntaxError:无法在模块外部使用import语句

我正在尝试将其导入布局组件,如下所示...

import $ from "jquery";
import {Foundation} from 'foundation-sites/js/foundation.core.js'
Foundation.addToJquery($);
import {Triggers} from 'foundation-sites/js/foundation.util.triggers'
Triggers.init($, Foundation);
// Components
import Header from "../../components/Header";
import Footer from "../../components/Footer";

/**
 * Default layout for pages containing a header and footer
 * @param props
 * @constructor
 */
const DefaultLayout = (props) => {
    useEffect(() => {
        console.log($);
    }, []);

    return (
        <>
            <Head>
                <title>{props.pageTitle}</title>
            </Head>
            <Header />
            {props.children}
            <Footer />
        </>
    )
};

export default DefaultLayout;

(非常类似于this suggested solution,但是无论我如何更改导入的名称,我都会收到相同的错误)。

jquery typescript zurb-foundation next.js
1个回答
0
投票

没关系-意识到我没有使用Foundation的dist。

© www.soinside.com 2019 - 2024. All rights reserved.