
小程序
2b勿扰
专注技术的研究
展开
-
微信小程序(微信支付,收获地址)
后端的接口地址请参照微信文档后端apiwx.request({ url: '支付接口地址', method:'get', data:{ openId:openId }, success: function(res){ //res为后端返回的参数 wx.requestPayment({ ...原创 2019-12-23 22:47:33 · 20209 阅读 · 0 评论 -
微信小程序(组件的复用)
// component/my-behavior/my-behavior.jslet myBehavior = require('../behavior.js');Component({ behaviors: [myBehavior], /** * 组件的属性列表 */ properties: { dataA:{ type:String, ...原创 2019-12-23 20:58:12 · 20955 阅读 · 0 评论 -
微信小程序(组件的数据监听)
// component/my-obs/my-obs.jsComponent({ /** * 组件的属性列表 */ properties: { dataA:{ type:String, value:'xxxxx', observer:function(newVal,oldVal,change){ console.lo...原创 2019-12-23 20:51:39 · 26784 阅读 · 0 评论 -
微信小程序(组件的生命周期)
// component/my-count/my-count.jsComponent({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { counter: 1 }, /** * 组件的方法列表 */ methods: { increase...原创 2019-12-23 12:36:22 · 20158 阅读 · 0 评论 -
微信小程序(页面获取组件实例对象来操做组件)
<!--index.wxml--><view class="container"> <button bindtap="count">计数</button> <my-count id="count"></my-count></view>//index.js//获取应用实例const app = g...原创 2019-12-23 12:13:06 · 24987 阅读 · 0 评论 -
微信小程序(tab栏的封装和使用)
my-tab.js// component/my-tab/my-tab.jsComponent({ /** * 组件的属性列表 */ properties: { tabArr:{ type:Array, value:[] } }, /** * 组件的初始数据 */ data: { currentInd...原创 2019-12-23 11:33:33 · 20362 阅读 · 0 评论 -
微信小程序(组件之间的事件的传递)
page页面js//index.js//获取应用实例const app = getApp()Page({ data: { title:"这是页面传的数据" }, onLoad: function () { }, search:function(e){ console.log(e.detail.searchText); }})page...原创 2019-12-23 11:18:07 · 21138 阅读 · 0 评论 -
微信小程序(组件样式隔离的解决方案)
在组件的js文件中添加styleIsolation,页面中css就会作用于组件// component/my-wxss/my-wxss.jsComponent({ options: { styleIsolation: 'shared' }, /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 ...原创 2019-12-23 10:55:18 · 23566 阅读 · 0 评论 -
微信小程序(多插槽的使用)
首先在组件中配置多插槽// component/my-conp/my-conp.jsComponent({ options: { multipleSlots: true // 在组件定义时的选项中启用多slot支持 }, /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data...原创 2019-12-23 00:01:22 · 20958 阅读 · 0 评论 -
微信小程序(组件之间的引用和数据,样式的传递)
首先先创建组件,在其他组件的json或页面或全局json中用如下方法进行引用引用{ "component": true, "usingComponents": { "my-conp2": "/component/my-conp2/my-conp2" }}使用<view class="box"> <text>这是我创建的第一个自定义组件...原创 2019-12-22 23:58:24 · 20407 阅读 · 0 评论 -
微信小程序(scroll-view实现 上拉刷新,下拉加载)
<import src="../../templates/movie-templates/movie-templates.wxml" /><scroll-view scroll-y="true" style="height:100vh;" bindscrolltolower="loadMore"> <view class="movie_list"> ...原创 2019-12-22 23:11:41 · 20946 阅读 · 0 评论 -
微信小程序(获取标签节点的信息)
小程序是没DOM的想要获取标签信息采用官方提供的api,用法如下:/** * 生命周期函数--监听页面加载 */ onLoad: function(options) { var that = this; const query = wx.createSelectorQuery(); //创建对象 query.select('.search_box').bo...原创 2019-12-22 20:34:31 · 22842 阅读 · 0 评论 -
微信小程序(模块的使用)
//JS代码var msg = "hello world";//commonjs模块化导出var num = function (num1, num2) { return num1 + num2;}module.exports = { message: msg, add: num}<!--pages/index/index.wxml--><wxs ...原创 2019-12-21 23:32:25 · 20869 阅读 · 0 评论 -
微信小程序(模板的使用)
<template name="courseList"> <view class="item"> <view class="item_img"> <image src="{{course.img}}"></image> </view> <view class="item_name"...原创 2019-12-21 23:19:47 · 20212 阅读 · 0 评论 -
微信小程序(拍照功能的使用)
takePhoto: function() { const ctx = wx.createCameraContext() ctx.takePhoto({ quality: 'high', success: (res) => { this.setData({ src: res.tempImagePath ...原创 2019-12-21 19:59:05 · 21874 阅读 · 0 评论 -
微信小程序(音乐视频播放)
Page({ /** * 页面的初始数据 */ data: { poster: '../../images/sp2.png', name: '白驹', author: '徐绍斌', src: 'http://ws.stream.qqmusic.qq.com/C4000045NySZ4TNK0x.m4a?guid=2308271380&v...原创 2019-12-21 19:47:45 · 20579 阅读 · 1 评论 -
微信小程序(表单的使用)
<!--pages/index/index.wxml--><form bindsubmit="formSubmit" bindreset="formReset"> <view class="section"> <input name="input" placeholder="请输入" bindblur="inputFN"></in...原创 2019-12-21 19:03:57 · 13490 阅读 · 0 评论 -
微信小程序(列表渲染)
Page({ /** * 页面的初始数据 */ data: { list:[] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var courseList = [{ img:"../../images/sp2.png", name:"Spring...原创 2019-12-21 15:15:33 · 13351 阅读 · 0 评论 -
微信小程序(小程序的生命周期)
Page({ /** * 页面的初始数据 */ data: { textstr:1 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log("load"); }, /** * 生命周期函数--监听页面初次渲染完成 */ onRea...原创 2019-12-21 15:03:03 · 13306 阅读 · 0 评论