<view class="boxb-s-right-1"> <text class="boxb-s-text-1">进入学习</text> </view> 我想通过这个按钮,直接跳转到/pages/lrs/lrs.wxss,帮我写一下吧
时间: 2024-09-20 10:01:49 浏览: 44
在Vue.js中,你可以创建一个点击事件绑定的按钮组件,并使用`v-link`指令来实现在用户点击时跳转到指定页面。这里是一个例子:
```html
<template>
<button class="boxb-s-right-1 boxb-s-btn" @click="goToLRSPage">
<text class="boxb-s-text-1">进入学习</text>
</button>
</template>
<script>
export default {
methods: {
goToLRSPage() {
this.$router.push('/pages/lrs/lrs.wxss');
}
}
}
</script>
<style scoped>
.boxb-s-right-1 {
/* 根据实际样式设置 */
}
.boxb-s-text-1 {
/* 样式设置 */
}
</style>
```
在这个例子中,我们假设已经设置了Vue Router来管理路由。如果还没有配置,你需要先安装并引入Vue Router,然后在Vue实例中注册你的路由。
相关问题
<template> <div class="box"> <el-container> <el-header class="tou"> <myhead></myhead> </el-header> <el-container> <el-aside class="zuo"> <myleft></myleft> </el-aside> <el-container> <el-main class="you"> <router-view></router-view> </el-main> </el-container> </el-container> </el-container> </div> </template> <script scoped > import myhead from "../components/myhead.vue" import myleft from "../components/myleft.vue" export default { components: { myhead, myleft, } } </script> <style> .box { height: calc(100vh - 60px); width: 100vw; display: flex; min-width: 700px; overflow-y: hidden; } body { overflow-x: hidden; margin-left: 0px; margin-top: 0px; } .tou { height: 50px; background-color: rgb(0, 0, 0); } .zuo { width: 200px; height: 100%; overflow-y: scroll; } .you { flex: 9; height: 100%; background: #f9ffb9; position: fixed; width: 100%; float: left; margin-left: -100px; } </style> zuo的滚动条拉不动
抱歉,我的建议有误。你的代码中,`.zuo` 元素的高度已经被正确计算,可以出现滚动条。但是,你在 `.you` 元素中设置了 `position: fixed;` 样式,导致它脱离了普通文档流,覆盖在了 `.zuo` 元素上方,导致无法操作 `.zuo` 元素的滚动条。
你可以尝试把 `.you` 元素的 `position` 属性改为 `absolute`,并且在 `.qb` 元素上添加 `position: relative;` 样式,这样就可以让 `.you` 元素相对于 `.qb` 元素定位,不会遮盖 `.zuo` 元素了。
上述211行附近的代码如下,请具体指出问题 def build_targets(self, p, targets): # Build targets for compute_loss(), input targets(image,class,x,y,w,h) na, nt = self.na, targets.shape[0] # number of anchors, targets tcls, tbox, indices, anch = [], [], [], [] gain = torch.ones(7, device=targets.device) # normalized to gridspace gain ai = torch.arange(na, device=targets.device).float().view(na, 1).repeat(1, nt) # same as .repeat_interleave(nt) targets = torch.cat((targets.repeat(na, 1, 1), ai[:, :, None]), 2) # append anchor indices g = 0.5 # bias off = torch.tensor([[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], # j,k,l,m # [1, 1], [1, -1], [-1, 1], [-1, -1], # jk,jm,lk,lm ], device=targets.device).float() * g # offsets for i in range(self.nl): anchors = self.anchors[i] gain[2:6] = torch.tensor(p[i].shape)[[3, 2, 3, 2]] # xyxy gain # Match targets to anchors t = targets * gain if nt: # Matches r = t[:, :, 4:6] / anchors[:, None] # wh ratio j = torch.max(r, 1. / r).max(2)[0] < self.hyp['anchor_t'] # compare # j = wh_iou(anchors, t[:, 4:6]) > model.hyp['iou_t'] # iou(3,n)=wh_iou(anchors(3,2), gwh(n,2)) t = t[j] # filter # Offsets gxy = t[:, 2:4] # grid xy gxi = gain[[2, 3]] - gxy # inverse j, k = ((gxy % 1. < g) & (gxy > 1.)).T l, m = ((gxi % 1. < g) & (gxi > 1.)).T j = torch.stack((torch.ones_like(j), j, k, l, m)) t = t.repeat((5, 1, 1))[j] offsets = (torch.zeros_like(gxy)[None] + off[:, None])[j] else: t = targets[0] offsets = 0 # Define b, c = t[:, :2].long().T # image, class gxy = t[:, 2:4] # grid xy gwh = t[:, 4:6] # grid wh gij = (gxy - offsets).long() gi, gj = gij.T # grid xy indices # Append a = t[:, 6].long() # anchor indices indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices tbox.append(torch.cat((gxy - gij, gwh), 1)) # box anch.append(anchors[a]) # anchors tcls.append(c) # class return tcls, tbox, indices, anch
根据你提供的代码,第 211 行出现错误的地方是在 indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) 这一行。
问题出现在使用 clamp_() 函数时,尝试将 Float 类型的 gj 和 gi 转换为 __int64 类型。由于 clamp_() 函数会直接修改张量的值,而且 __int64 类型不能容纳 Float 类型的值,因此会导致类型转换错误。
要解决这个问题,你可以使用 clamp() 函数而不是 clamp_() 函数,这样就可以返回一个新的张量,而不会修改原始张量的值。修改代码如下:
```python
indices.append((b, a, gj.clamp(0, int(gain[3]) - 1), gi.clamp(0, int(gain[2]) - 1))) # image, anchor, grid indices
```
这样修改后,应该就能解决 RuntimeError: result type Float can't be cast to the desired output type __int64 的问题了。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![application/x-dosexec](https://img-home.csdnimg.cn/images/20210720083343.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)