app之pages添加跳转页面

简单的页面跳转

  1. <View className='at-row'>
  2. <View className='at-col' style='z-index:1;position:fixed;top:0rpx'><Navigator url='../login/index' open-type='redirect' hover-class='navigator-hover'>跳转到新页面</Navigator></View>
  3. </View>

加了一些属性,试了半天也没有试出,还加了一些属性,并手动在 dist /app.json 加了跳转到的目录,还是不行。后来发现需要在 app.js 的 config 的pages 添加需要跳转的目录,否则小程序是不会认的。添加了以后成功了。
注意:添加的时候不要写.js 直接写js 的文件名就好。跳转的src 也不要写后缀 .js
app.js

  1. class App extends Component {
  2. config = {
  3. pages: [
  4. 'pages/index/index',
  5. 'pages/login/index'
  6. ],
  7. window: {
  8. backgroundTextStyle: 'light',
  9. navigationBarBackgroundColor: '#fff',
  10. navigationBarTitleText: 'WeChat',
  11. navigationBarTextStyle: 'black'
  12. }}}

pages/index/index

  1. <View className='at-row'>
  2. <View className='at-col' style='z-index:1;position:fixed;top:0rpx'><Navigator url='../login/index' open-type='redirect' hover-class='navigator-hover'>跳转到新页面</Navigator></View>
  3. </View>