Micro-Letter Applet-Message prompt box instance _javascript tips

Source: Internet
Author: User

Android is very familiar to toast. Toast is also an important way of message prompting in the development of micro-credit programs.

Prompt box:

Wx.showtoast (OBJECT)

Show message Prompt box

Object parameter Description:

Sample code:

Wx.showtoast ({
 title: ' Success ',
 icon: ' Success ',
 duration:2000
})

Wx.hidetoast ()

Hide Message Prompt box

Wx.showtoast ({
 title: ' Loading ',
 icon: ' Loading ',
 duration:10000
})

settimeout (function () {
 wx.hidetoast ()
},2000)

Wx.showmodal (OBJECT)

Show modal Bounce window

Object parameter Description:

Sample code:

Wx.showmodal ({
 title: ' Hint ',
 content: ' This is a modal pinball window ',
 success:function (res) {
  if (res.confirm) {
   console.log (' user clicks OK '}}}
)

Wx.showactionsheet (OBJECT)

Show Action Menu

Object parameter Description:

Success Return Parameter Description:

Sample code:

Wx.showactionsheet ({
 itemList: [' A ', ' B ', ' C '],
 success:function (res) {
  if (!res.cancel) {
   Console.log (Res.tapindex)}}
)

Set navigation bar

Wx.setnavigationbartitle (OBJECT)

Dynamically sets the title of the current page.

Object parameter Description:

Sample code:

Wx.setnavigationbartitle ({
 title: ' Current page '
})

Wx.shownavigationbarloading ()

Displays the navigation bar on the current page to load the animation.

Wx.hidenavigationbarloading ()

Hide the navigation bar to load the animation.

Page Jump:

Wx.navigateto (OBJECT)

Keep the current page, jump to a page in the application, use Wx.navigateback can return to the original page.

Object parameter Description:

Sample code:

Wx.navigateto ({
 URL: ' test?id=1 '
})
Test.js
Page ({
 onload:function (option) {
  console.log (option.query)
 }
})

Note: In order not to let users in the use of small programs caused by the problem, we specify that the page path can only be five layers, please try to avoid multi-level interactive mode.

Wx.redirectto (OBJECT)

Closes the current page and jumps to a page within the application.

Object parameter Description:

Sample code:

Wx.redirectto ({
 URL: ' test?id=1 '
})

Wx.navigateback (OBJECT)

Closes the current page and returns to the previous or multilevel page. You can get the current page stack by Getcurrentpages () and decide how many layers you want to return.

Object parameter Description:

Animation:

Wx.createanimation (OBJECT)

Create an animated instance animation. Invokes the instance's method to describe the animation. Finally, the animation property of the animation data passed to the component is exported through the export method of the animation instance.

Note: The export method will clear the previous animation operation after each call

Object parameter Description:

var animation = wx.createanimation ({
 transformorigin: "50% 50%",
 duration:1000,
 timingfunction: "Ease",
 delay:0
})

Animation

An animation instance can call the following methods to describe the animation, which returns itself after the call is completed, supporting the writing of chained calls.

Style:

Rotating:

Scaling:

Offset:

Tilt:

Matrix variants:

Animation queues

Call step () after calling the animation action method to represent a set of animation finishes, you can invoke any number of animation methods in a set of animations, all animations in a set of animations begin at the same time, and a set of animations is completed before the next set of animations. Step can pass in a configuration parameter like Wx.createanimation () to specify the configuration of the current group animation.

Example:

 <view animation= ' {{animationdata}} ' style= ' Background:red;height:100rpx;width : 100rpx "></view> 
Page ({data: {animationdata: {}}, Onshow:function () {var animation = Wx.createanimation ({duration:1000,
   Timingfunction: ' Ease ',}) This.animation = Animation Animation.scale (2,2). Rotate (). Step () This.setdata ({
    AnimationData:animation.export ()}) settimeout (function () {animation.translate (). Step () This.setdata ({ AnimationData:animation.export ()})}.bind (this), 1000)}, Rotateandscale:function () {//rotate simultaneously enlarge This.animat Ion.rotate. Scale (2, 2). Step () This.setdata ({animationData:this.animation.export ()})}, Rotatethenscale:fu Nction () {////First rotate and then enlarge this.animation.rotate. Step () This.animation.scale (2, 2). Step () This.setdata ({Animati OnData:this.animation.export ()})}, Rotateandscalethentranslate:function () {//rotate and zoom in at the same time, then Pan this.animation.ro Tate. Scale (2, 2). Step () This.animation.translate (+). Step ({duration:1000}) This.setdata ({Animationdat A:this.animation.export()
  })
 }
})

 

Wx.hidekeyboard ()

Close the keyboard.

Wx.stoppulldownrefresh ()

Stops the current page Drop-down refresh. See page-related event handling functions.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.