HBuilderX開發(fā)一個簡單的微信小程序的實現(xiàn)步驟
一、配置
在微信開發(fā)者工具的設置中開啟,如圖:
在HBuilderX中新建項目,選擇uni-app,如圖:
在HBuilderX中編寫代碼
目錄結構如圖:
編寫代碼:
index.less
.content{ padding: 0 40rpx; image{ width: 100%; } .title{ display: block; text-align: center; font-size: 50rpx; font-weight: bold; } .operate{ text-align: center; margin-top: 30rpx; .btn{ width: 200rpx; height: 80rpx; display: inline-block; } .btn:first-of-type{ margin-right: 40rpx; } } .message{ font-size: 34rpx; margin: 15rpx 0; color: #333; } }
App.vue
<script> export default { onLaunch: function() { console.log('App Launch') }, onShow: function() { console.log('App Show') }, onHide: function() { console.log('App Hide') } } </script> <style> /*每個頁面公共css */ </style>
index.vue
<template> <view class="content"> <image src="../../static/g1.gif" mode="widthFix"></image> <text class="title">鵲伴相依間,佳期又一年</text> <text class="title">做我女朋友吧!</text> <view class="operate"> <button type="primary" class="btn" @tap="agree">好呀</button> <button type="warn" class="btn" @tap="disagree">不好</button> </view> <view class="message" v-for="one in love":key="one">{{one}}</view> </view> </template> <script> export default { data() { return { love:[], timer:{} } }, onLoad() { this.back=uni.getBackgroundAudioManager() this.back.src="http://140.143.132.225/love/pdd.mp3" this.back.title="音樂" this.back.play() }, onShow(){ this.love=[] this.timer={} let msg={ 2000: "我愛你!", 4000: " I love you! (英語)", 6000: "愛しています (日語)", 8000: " ich liebe dich! (德語)", 10000: "я люблю тебя! (俄語)", 12000: "ti amo! (意大利語)", 14000: "te amo! (西班牙語)", 16000: "? ????! (韓語)", 18000: "jeg elsker dig! (丹麥語)", 20000: "σ 'αγαπ?! (希臘語)" } let ref=this; for(let key in msg){ let t=setTimeout(function(){ ref.love.push(msg[key]) delete ref.timer[key] },key) ref.timer[key]=t } }, onHide:function(){ for(let key in this.timer){ clearTimeout(this.timer[key]) } }, methods: { agree:function(){ uni.showToast({ icon:"none", title:"我就知道你一定會同意", duration:4000 }) }, disagree:function(){ uni.showModal({ title:"要不要當我女朋友", content:"(:", cancelText:"拒絕", confirmText:"同意", success:function(res){ if(res.confirm){ uni.showToast({ icon:"none", title:"我就知道你一定會同意", duration:4000 }) } else{ uni.showToast({ icon:"none", title:"你錯過了一個億", duration:4000 }) } } }) } } } </script> <style lang="less"> @import url("index.less"); </style>
二、運行
選擇運行—運行到小程序模擬器—微信開發(fā)者工具
(如果出現(xiàn)編譯不通過的問題,可在工具的插件安裝里安裝相應的插件)
編譯完成后,可在微信開發(fā)者工具中預覽和發(fā)布(選擇上傳操作,填相關信息,并在微信公眾號后臺網(wǎng)站實現(xiàn)審核和發(fā)布)
到此這篇關于HBuilderX開發(fā)一個簡單的微信小程序的實現(xiàn)步驟的文章就介紹到這了,更多相關HBuilderX開發(fā)小程序內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
如何使Chrome控制臺支持多行js模式——意外發(fā)現(xiàn)
一直以來,Chrome控制臺都缺少象IE調試臺那樣的多行執(zhí)行模式,今天意外發(fā)現(xiàn)Chrome其實也支持多行模式2013-06-06將json當數(shù)據(jù)庫一樣操作的javascript lib
使用javascript操作JSON的類庫TAFFY DB,具體介紹了:查詢數(shù)據(jù)、添加數(shù)據(jù)、刪除數(shù)據(jù)、修改數(shù)據(jù)。2013-10-10微信小程序下面商品左右滑動上面tab也跟隨變動功能實現(xiàn)
這篇文章主要介紹了小程序下面商品左右滑動上面tab也跟隨變動功能,也就是點擊tab切換下面的商品信息,滑動下面的商品信息tab也進行切換,本文給大家分享實現(xiàn)代碼,需要的朋友可以參考下2022-07-07ECMAScript6函數(shù)剩余參數(shù)(Rest Parameters)
這篇文章主要介紹了ECMAScript6函數(shù)剩余參數(shù)(Rest Parameters)的相關資料,需要的朋友可以參考下2015-06-06JavaScript callback回調函數(shù)用法實例分析
這篇文章主要介紹了JavaScript callback回調函數(shù)用法,結合實例形式分析了callback回調函數(shù)的概念、功能、應用場景及相關使用技巧,需要的朋友可以參考下2018-05-05JavaScript Konami Code 實現(xiàn)代碼
JavaScript Konami Code 實現(xiàn)代碼2009-07-07