1. 在js文件中实现按钮点击事件,跳转到另外一页:
// index.js

Page({
  // 按钮点击事件
  buttonClick: function() {
    wx.navigateTo({
      url: '/pages/otherPage/otherPage', // 跳转的页面路径
    })
  }
})
  1. 在json文件中配置页面路由:
// index.json

{
  "navigationBarTitleText": "首页",
  "usingComponents": {}
}
  1. 在wxml文件中添加按钮并绑定点击事件:
<!-- index.wxml -->

<view class="container">
  <button bindtap="buttonClick">跳转</button>
</view>
  1. 在wxss文件中设置样式:
/* index.wxss */

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

button {
  padding: 10px 20px;
  background-color: #007AFF;
  color: #FFF;
  border: none;
  border-radius: 5px;
}

这样,当点击按钮时,就会跳转到名为"otherPage"的页面

微信小程序开发代码实现按钮查询跳转到另外一页jsjsonwxmlwxss代码实现

原文地址: https://www.cveoy.top/t/topic/hPVk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录