简体   繁体   English

REACT-NATIVE - abcjs - ReferenceError:找不到变量:元素

[英]REACT-NATIVE - abcjs - ReferenceError: Can't find variable: Element

import abcjs from 'abcjs';

export default class MusicScore extends Component {
    constructor(props) {
        super(props);
        this.state={
            data: this.props.navigation.getParam('abctune'),
        }
    }
    render(){
        data = this.state.data;
        renderScore = () => {
            abcjs.renderAbc('notation', data);
        }
        return(
            <WebView 
                source={
                    {html: `
                        <!DOCTYPE html>
                        <html lang="en">
                        <head>
                            <meta charset="UTF-8">
                            <meta name="viewport" content="width=device-width, initial-scale=1.0">
                            <title>Document</title>
                        </head>
                        <body>
                            <div id="notation"></div>
                        </body>
                        </html>
                    `}
                }
                domStorageEnabled
                javaScriptEnabled
                injectJavaScript={renderScore}
            />
        );
    }
}

The code above produces the following上面的代码产生以下内容

在此处输入图像描述

OUTPUT输出

dev enviornment:开发环境:

OS: Windows 10操作系统:Windows 10

node: v12.10.0节点:v12.10.0

Android Studio: 3.5.2安卓工作室:3.5.2

installed via package manager:通过包管理器安装:

npm install --save abcjs npm 安装 --save abcjs

Unfortunately, you need a DOM set up.不幸的是,您需要设置 DOM。 I haven't used react-native, so I'm not sure if this will work:我没有使用过 react-native,所以我不确定这是否有效:

What works for me when using a SSR package (like Nuxt) is to change the import to later in the process.使用 SSR 包(如 Nuxt)时对我有用的是将导入更改为稍后的过程。 So:所以:

mounted() {
  const abcjs = require('abcjs');
}

Is there something analogous in react-native? react-native 中有类似的东西吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native ReferenceError 找不到变量 - React Native ReferenceError Can't find variable 自定义字体 React-Native,[未处理的承诺拒绝:ReferenceError:找不到变量:ExpoFontLoader] - Custom font React-Native, [Unhandled promise rejection: ReferenceError: Can't find variable: ExpoFontLoader] react-native [iOS] RCTAssert RCTFormatError 165 ReferenceError:找不到变量:typeAnnotation - react-native [iOS] RCTAssert RCTFormatError 165 ReferenceError: Can't find variable: typeAnnotation React-native打字稿:找不到变量:React - React-native typescript: Can't find variable: React ReferenceError: 找不到变量: False - React Native (Hookstate) - ReferenceError: Can't find variable: False - React Native (Hookstate) ReferenceError:找不到变量:hasLocationPermission - React Native - ReferenceError: Can't find variable: hasLocationPermission - React Native 使用 Expo “ReferenceError:找不到变量:警报”反应本机 - React Native with Expo “ReferenceError: Can't find variable: Alert” ReferenceError:找不到变量:导航 [React Native] - ReferenceError: Can't find variable: navigation [React Native] ReferenceError:找不到变量:在本机反应中导航 - ReferenceError: Can't find variable: navigation in react native react-native:导入后找不到变量样式表 - react-native: Can't find variable Stylesheet after importing it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM