0

我先编写了一个欢迎页面然后编写了一个容器在容器上设置了一个监视器,但是在我点击的时候把报错页面未定义未发现报错信息如下:thirdScriptError
sdk uncaught third Error
page is not defined
ReferenceError: page is not defined

at http://127.0.0.1:24407/appservice/pages/welcome/welcome.js:3:1
at require (http://127.0.0.1:24407/appservice/__dev__/WAService.js:1:888689)
at <anonymous>:14:7
at HTMLScriptElement.scriptLoaded (http://127.0.0.1:24407/appservice/appservice?t=1549933939835:1198:21)
at HTMLScriptElement.script.onload (http://127.0.0.1:24407/appservice/appservice?t=1549933939835:1210:20)
    
    
    
    
    Page[pages/welcome/welcome] not found. May be caused by: 1. Forgot to add page route in app.json. 2. Invoking Page() in async task.
    
    百度搜索说是我app.json页面顺序排错了,经更改仍然报错,更改如下:
    "pages":[
        "pages/welcome/welcome",
        "pages/index/index",
        "pages/powerdata/powerdata",
        "pages/powercontrol/powercontrol",
        "pages/location/location"
              ],
              
        或者完全关闭在重新启动微信小程序开发者工具,我是先关闭程序在重启电脑,仍然无用报错。求大神指点,代码如下:
welcome.js
page({
  onTapJump: function (event) {
    wx.redirectTo({
      url: "../index/index",
      success: function () {
        console.log("jump success")
      },
      fail: function () {
        console.log("jump failed")
      },
      complete: function () {
        console.log("jump complete")
      }
    });
  }
})

welcome.json
{
}

welcome.wxml
<view class="container">
<image class="logo" src="../images/avatar-1.png"></image>
<text class="motto">欢迎使用</text>
<view catchtap="onTapJump" class="journey-container">
<text class="journey">进入</text>
</view>
</view>

welcom.wxss
.container{
  display:flex;
  flex-direction:column;
  align-items:center;
}

.logo{
width:200rpx;
height:200rpx;
margin-top:10rpx;
}

.motto{
margin-top:100rpx;
font-size:32rpx;
font-weight:bold;
color:black;
}

.journey-container{
margin-top:200rpx;
border:1px solid#EA5A3C;
width:200rpx;
height:80rpx;
border-radius:5px;
text-align:center;
}

.journey{
font-size:22rpx;
font-weight:bold;
line-height:80rpx;
color:black;
}

text{
font-family: Microsoft YaHei;
}

app.js
App({
  onLaunch: function () {
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
    // 获取用户信息
    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
          wx.getUserInfo({
            success: res => {
              // 可以将 res 发送给后台解码出 unionId
              this.globalData.userInfo = res.userInfo

              // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
              // 所以此处加入 callback 以防止这种情况
              if (this.userInfoReadyCallback) {
                this.userInfoReadyCallback(res)
              }
            }
          })
        }
      }
    })
  },
  globalData: {
    userInfo: null
  }
})

app.json
{
  "pages":[
    "pages/welcome/welcome",
    "pages/index/index",
    "pages/powerdata/powerdata",
    "pages/powercontrol/powercontrol",
    "pages/location/location"
  ],
  "window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "芯界BMS管理系统",
    "navigationBarTextStyle":"black"
  }
}

app.wxss
.container {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 200rpx 0;
  box-sizing: border-box;
} 
      

5 天前提问

1 个回答

0

clipboard.png

加上data,注册页面的时候需要用到path和data

你可能感兴趣的

推广链接