1 : Create A Native App in Ubuntu

0

1/ terminal
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH


npm install npm@latest -g
npm install node@latest -g


npm install react-native-cli -g
npm install expo-cli -g
npm install -g vue-native-cli
2/Tạo prject
vue-native init {nameproject}
3: Configure the React Native Packager
sửa file vueTransformerPlugin.js


// For React Native 0.59 and above
var upstreamTransformer = require("metro-react-native-babel-transformer");

var vueNativeScripts = require("vue-native-scripts");
var vueExtensions = ["vue"];

module.exports.transform = function({ src, filename, options }) {
  if (vueExtensions.some(ext => filename.endsWith("." + ext))) {
    return vueNativeScripts.transform({ src, filename, options });
  }
  return upstreamTransformer.transform({ src, filename, options });
};

 và metro.config.js 


const { getDefaultConfig } = require("metro-config");

module.exports = (async () => {
  const {
    resolver: { sourceExts }
  } = await getDefaultConfig();
  return {
    transformer: {
      babelTransformerPath: require.resolve("./vueTransformerPlugin.js"),
      getTransformOptions: async () => ({
        transform: {
          experimentalImportSupport: false,
          inlineRequires: false,
        },
      })
    },
    resolver: {
      sourceExts: [...sourceExts, "vue"]
    }
  };
})();
4: Chạy npm và kết nối cap usb mode debuging với điện thoại
npm start
demo

Tags

Post a Comment

0Comments
Post a Comment (0)