1

我尝试启动 vue-native。

$npm install -g vue-native-cli expo-cli

在我的项目中,我安装了

$ npm install vue-native-core vue-native-helper --save
$ npm install vue-native-scripts --save-dev

我创建 vueTransformerPlugin.js 和 metro.config.js 就像指南告诉我的那样 [https://vue-native.io/docs/installation.html][1]

当我启动项目时,我有这个问题

$ npm run web

网页编译失败。//vueexpocli/node_modules/expo/AppEntry.js Module not found: Can't resolve '../../App' in '//vueexpocli/node_modules/expo'

我看了很多论坛

// app.json
        {
      "expo": {
        "name": "vueexpocli",
        "slug": "vueexpocli",
        "version": "1.0.0",
        "orientation": "portrait",
        "icon": "./assets/icon.png",
        "splash": {
          "image": "./assets/splash.png",
          "resizeMode": "contain",
          "backgroundColor": "#ffffff"
        },
        "updates": {
          "fallbackToCacheTimeout": 0
        },
        "assetBundlePatterns": [
          "**/*"
        ],
        "ios": {
          "supportsTablet": true
        },
        "web": {
          "favicon": "./assets/favicon.png"
        },
        "packagerOpts": {
          "config": "metro.config.js",
          "sourceExts": [
            "vue",
            "js",
            "json",
            "ts",
            "tsx"
          ]
        }
      }
    }
//package.json
    {
      "main": "node_modules/expo/AppEntry.js",
      "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "web": "expo start --web",
        "eject": "expo eject",
        "lint": "eslint ./src ./App.vue --ext .js,.vue",
        "lint:fix": "eslint ./src ./App.vue --ext .js,.vue --fix"
      },
      "dependencies": {
        "expo": "~38.0.8",
        "expo-status-bar": "^1.0.2",
        "react": "~16.11.0",
        "react-dom": "~16.11.0",
        "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
        "react-native-web": "~0.11.7",
        "vue-native-core": "^0.1.4",
        "vue-native-helper": "^0.1.4",
        "vue-native-router": "~0.1.1"
      },
      "devDependencies": {
        "babel-eslint": "^10.0.3",
        "eslint": "^6.5.1",
        "eslint-config-prettier": "^6.4.0",
        "eslint-plugin-prettier": "^3.1.1",
        "eslint-plugin-react": "^7.16.0",
        "eslint-plugin-vue": "^5.2.3",
        "jest-expo": "^35.0.0",
        "prettier": "^1.18.2",
        "react-test-renderer": "16.8.6",
        "vue-native-scripts": "~0.1.4"
      },
      "private": true
    }

我将 App.js 重命名为 App.vue 并更改

// App.vue
    <template>
      <view class="container">
        <text class="text-color-primary">My Vue Native App</text>
      </view>
    </template>
    
    <style>
    .container {
      background-color: white;
      align-items: center;
      justify-content: center;
      flex: 1;
    }
    .text-color-primary {
      color: blue;
    }
    </style>

你有什么想法 ?我看到很多论坛。我尝试将 AppEntry.js App 中的重命名为 App.vue,但我也遇到了问题。

请,请,帮助我!

4

1 回答 1

1

我相信(截至这篇文章)vue-native web 模式目前已损坏 https://github.com/GeekyAnts/vue-native-core/issues/268

(具体的错误信息https://github.com/GeekyAnts/vue-native-core/issues/235 )

问题已经公开了一段时间,所以希望在 2021 年得到修复:D

现在只需要测试/运行为 android/ios 而不是 web。

于 2021-01-04T19:16:56.653 回答