为什么Vue Router(0.7.13)与子路由不匹配?

时间:2016-09-30 10:20:21

标签: javascript json components vue.js vue-router

如果我这样做:

'/sales': {
    component: NotFound,
    subRoutes: {
      '/': {
        component: NotFound
      },
      '/report': {
        name: 'sales.report',
        component: SalesReport
      },
      '/create': {
        name: 'sales.create',
        component: SalesCreate
      },
      '/edit/:i': {
        name: 'sales.edit',
        component: SalesEdit
      },
      '/list': {
        name: 'sales.list',
        component: SalesList
      }
    }
  }

Vue将始终转到组件NotFound,无论sales URL是什么(我猜它与父级匹配)。

但如果我这样写:

'sales/report': {
   name: 'sales.report',
   component: SalesReport
},
'sales/create: {
   name: 'sales.create',
   component: SalesCreate
}

按预期工作。我的问题:为什么我不能使用 subRoutes ? (使用Vue 1.0.26)

1 个答案:

答案 0 :(得分:1)

按名称调用嵌套路由应该没有问题。

https://jsfiddle.net/662u1pah/4/

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellid"];  // fixme

    theGame *thegameObj = model[indexPath.section][indexPath.row];
    NSString *urlString = thegameObj.image;
    UIImageView *imageView = cell.imageView;

    [self imageAtURLString:urlString completion:^(UIImage *image, BOOL wasCached) {
        if (wasCached) imageView.image = image;
        else [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }];

    return cell;
}