【问题标题】:How import fabric-webpack to react-native?如何将 fabric-webpack 导入 react-native?
【发布时间】:2016-12-24 00:15:40
【问题描述】:

我有现有的 iOS swift 应用程序。我将它集成到 react-native。但是当我添加“从'react-fabricjs'导入{Canvas,Circle,Image,Path};”时我有错误 enter image description here

我的 package.json

{
  "name": "uploader",
  "version": "1.0.0",
  "private": true,
  "description": "Uploader",
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "react": "~15.3.0",
    "react-dom": "~15.3.0",
    "react-fabricjs": "^0.1.6",
    "react-native": "~0.34.0",
    "jsdom": "~9.9.1"
  }
} 

我的 index.ios.js

'use strict';
// 1
import React from 'react';
import {Canvas,Circle, Image, Path } from 'react-fabricjs';


import ReactNative, {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} from 'react-native';
// 2
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'yellow',
  },
  welcome: {
    fontSize: 35,
    color: 'green',
  },
});

// 3
class AddRatingApp extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>See you later alligator !</Text>
      </View>
    )
  }
}

// 4
AppRegistry.registerComponent('AddRatingApp', () => AddRatingApp);

如何将任何 React 库导入 react-native 应用程序?

【问题讨论】:

    标签: swift reactjs react-native


    【解决方案1】:

    任何使用 html/css/DOM 的库都不能与 React Native 一起使用。这是一个 html5 库,可以与 React 一起使用,但不能与 React Native 一起使用。

    【讨论】:

    • 感谢您的回答。还有没有办法连接 React 库?
    • React 库工作并且您正确导入它,但 React Native 将无法理解其中使用 html/ccs/dom 的库。
    • 您应该尝试找到一个能够完成您想要完成的工作的 react-native 库。这是一个很好的资源 - github.com/jondot/awesome-react-native
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-29
    • 1970-01-01
    • 2018-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    相关资源
    最近更新 更多