We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Learn more about funding links in repositories.
Report abuse
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[vue] vue和微信小程序写法上有什么区别?
The text was updated successfully, but these errors were encountered:
https://www.jianshu.com/p/d4a053599572
Sorry, something went wrong.
Vue使用类似HTML的模板语法,而微信小程序使用类似HTML和JavaScript混合的WXML语法。 vue
<template> <div> <h1>{{ message }}</h1> <button @click="handleClick">Click me</button> </div> </template>
miniprogram
<view> <text>{{ message }}</text> <button bindtap="handleClick">Click me</button> </view>
Vue使用单文件组件(.vue)来封装组件,而微信小程序使用JSON和WXML文件组合的方式来定义组件。 vue
<template> <div class="my-component"> <!-- 组件内容 --> </div> </template> <script> export default { // 组件逻辑 } </script> <style> .my-component { /* 组件样式 */ } </style>
// 组件的JSON配置文件 { "component": true, "usingComponents": {}, "options": {}, "style": {}, "template": "<view class='my-component'></view>", "methods": {} }
Vue使用双向数据绑定和响应式系统,而微信小程序使用单向数据绑定。 vue
<template> <div> <input v-model="message" /> <p>{{ message }}</p> </div> </template>
<view> <input bindinput="handleInput" value="{{ message }}" /> <text>{{ message }}</text> </view>
Vue使用CSS来定义组件的样式,而微信小程序使用类似CSS的WXSS语法。
vue
<template> <div class="my-component"> <!-- 组件内容 --> </div> </template> <style> .my-component { color: red; } </style>
/* 组件的WXSS样式文件 */ .my-component { color: red; }
Vue和微信小程序都有自己的生命周期钩子,但具体的钩子函数和触发时机有所不同。 vue
export default { created() { // 组件创建时触发 }, mounted() { // 组件挂载到DOM时触发 }, // ... }
Component({ created() { // 组件创建时触发 }, attached() { // 组件挂载到DOM时触发 }, // ... })
No branches or pull requests
[vue] vue和微信小程序写法上有什么区别?
The text was updated successfully, but these errors were encountered: