小编Fow*_*wad的帖子

React-Image-Annotate - SyntaxError:不能在模块外使用导入语句

我正在尝试使用react-image-annotate但是当我第一次尝试设置它时它给了我这个问题。

在此处输入图片说明

这是我如何使用它:

import React from 'react'
import ReactImageAnnotate from 'react-image-annotate'

function ImageAnnotator() {
    return (
        <ReactImageAnnotate
            selectedImage="https://images.unsplash.com/photo-1561518776-e76a5e48f731?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80"
            // taskDescription="# Draw region around each face\n\nInclude chin and hair."
            // images={[
            //     { src: 'https://example.com/image1.png', name: 'Image 1' },
            // ]}
            // regionClsList={['Man Face', 'Woman Face']}
        />
    )
}

export default ImageAnnotator
Run Code Online (Sandbox Code Playgroud)

如果这很重要,我正在使用 Next.js

更新 1 我尝试使用Alejandro Vales 建议的这个babel 插件。它给出了与以前相同的错误。这是babel我的关键package.json

    "babel": {
        "presets": [
            "next/babel"
        ],
        "plugins": [
            [
                "@babel/plugin-proposal-decorators",
                {
                    "legacy": true
                } …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs next.js

5
推荐指数
1
解决办法
466
查看次数

如何将默认引导类与样式组件一起使用?

display-4我想在 的样式中使用 bootstrap 的类styled-component

styled-component

const Heading = styled.h2`
        font-weight: bold,
        color: #968c8c,
`;
Run Code Online (Sandbox Code Playgroud)

我应该将display-4引导类放在styled-component. className='display-4'我知道每次使用该组件时我都可以这样做Heading,但肯定有更好的方法吗?

css reactjs bootstrap-4 styled-components

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