Weex Vue Framework
weex-vue-framework is a package that provides the Vue 2.0 framework for use with Weex, a platform enabling developers to build Android, iOS, and Web apps from a single codebase using modern web development skills. This package is an "auto-generated" component of the Vue.js ecosystem, specifically tailored for the Weex environment. The current stable version of the underlying Vue 2 series is 2.7.16, known as "Swan Song", which marked the final official release for Vue 2. It reached its End of Life (EOL) on December 31st, 2023, meaning it no longer receives new features, updates, or official security fixes. As such, this package, being intrinsically tied to Vue 2, is effectively deprecated. Its primary differentiator is its role in enabling Vue 2 applications to render natively on Weex-powered mobile environments, extending Vue's capabilities beyond the browser to native UI rendering.
Common errors
-
Vue is not defined
cause The Weex environment or its build process failed to correctly provide or register the Vue 2 framework.fixEnsure your entry file includes the `// { "framework": "Vue" }` comment or `"use weex:vue";` directive prologue at the very top, depending on your Weex SDK version. Verify that Weex-related build tools (e.g., `weex-toolkit`, `weex-loader`) are correctly installed and configured. -
Failed to compile template: ... Templates should be pre-compiled into render functions.
cause Attempting to use the `template` option in a Vue component within a Weex environment that is using a runtime-only build of Vue 2.fixEnsure all Vue components are defined as Single File Components (`.vue` files) and that your build process (e.g., Webpack with `weex-loader`) is correctly configured to pre-compile these templates into `render` functions. Do not use inline templates or `Vue.compile` in your runtime code. -
Error: Weex module 'xxx' not found.
cause Attempting to use a Weex native module (`weex.requireModule('xxx')`) that is not correctly implemented or registered in the native environment (iOS/Android).fixVerify that the native module 'xxx' is properly implemented and registered within your Android and iOS Weex projects. Check for case sensitivity or naming mismatches. Ensure your Weex SDK version supports the module or that any custom native modules are linked correctly. -
EOL/Obsolete Software: Vue 2 Detected.
cause This warning is issued by package managers (like npm) when they detect that your project depends on Vue 2, which has officially reached its End of Life.fixThis is a warning, not an error preventing compilation. The official fix is to migrate your project to Vue 3. If migration is not immediately feasible, you can explore Vue 2 Never-Ending Support (NES) from HeroDevs for continued security updates, or suppress the warning at your own risk.
Warnings
- breaking Vue 2, which this framework supports, reached its End of Life (EOL) on December 31st, 2023. This means it no longer receives official updates, bug fixes, or security patches, which can lead to critical security vulnerabilities and compatibility issues with newer platforms or browsers.
- gotcha This package is listed as "auto-generated" and is deeply integrated into the Weex platform's rendering pipeline. Direct usage, updates, or troubleshooting might require specific knowledge of the Weex build system and its internal handling of Vue.
- deprecated New feature development and official maintenance for this Vue 2 framework are effectively halted due to Vue 2's EOL. Relying on it for new projects or expecting new capabilities is not advisable.
- gotcha Weex often utilizes a 'runtime-only' build of Vue 2 for performance, which means component templates must be pre-compiled during the build process (e.g., using `weex-loader`). Attempting to use the `template` option or `Vue.compile` at runtime will fail.
Install
-
npm install weex-vue-framework -
yarn add weex-vue-framework -
pnpm add weex-vue-framework
Imports
- Vue
const Vue = require('weex-vue-framework')import Vue from 'weex-vue-framework'
- init
import init from 'weex-vue-framework/init'
import { init } from 'weex-vue-framework' - registerComponent
import { component } from 'weex-vue-framework'import { registerComponent } from 'weex-vue-framework'
Quickstart
/* file: src/App.vue */
<template>
<div class="wrapper">
<text class="message">Hello Weex with Vue 2!</text>
<text class="counter">Count: {{ count }}</text>
<button @click="increment" class="button">
<text class="button-text">Increment</text>
</button>
</div>
</template>
<script>
export default {
data () {
return {
count: 0
}
},
methods: {
increment () {
this.count++
console.log('Count incremented to:', this.count)
}
}
}
</script>
<style scoped>
.wrapper {
flex-direction: column;
justify-content: center;
align-items: center;
height: 800px; /* Weex requires explicit dimensions */
background-color: #f0f0f0;
}
.message {
font-size: 48px;
text-align: center;
margin-bottom: 30px;
color: #333;
}
.counter {
font-size: 36px;
color: #666;
margin-bottom: 40px;
}
.button {
background-color: #42b983;
padding: 20px 40px;
border-radius: 10px;
}
.button-text {
color: #ffffff;
font-size: 32px;
}
</style>
/* file: src/main.js - entry file for Weex build */
// The 'use weex:vue' directive is crucial for Weex to identify the framework.
// { "framework": "Vue" } // Alternative for Weex v0.16 and earlier
import Vue from 'vue'; // In a Weex project, this resolves to the Weex-adapted Vue runtime
import App from './App.vue';
// Weex requires the root element to be specified for the Vue instance.
// The #root element is typically provided by the Weex rendering environment.
new Vue({
el: '#root',
render: h => h(App)
});
// This example assumes a build process using weex-loader or similar,
// which bundles the .vue file into a JavaScript bundle for native Weex rendering.
// You would typically run 'weex create myapp' and then build/run the project.
// e.g., 'npm run build' and 'weex run android' or 'weex run ios'.