我正在尝试删除屏幕右侧显示的带有包含视图的 navigationLink 的 V 形符号。这是我的代码如下:
NavigationView {
List {
NavigationLink(destination: DynamicList()) {
ResultCard()
}
...
}
Run Code Online (Sandbox Code Playgroud)
Stack Overflow 上的其他答案建议使用如下内容:
NavigationLink(...)
.opacity(0)
Run Code Online (Sandbox Code Playgroud)
但是,这在我的情况下不起作用,因为将不透明度降低到 0 也会删除我尝试显示的视图。“.hidden”也是如此。我到处搜索过,我能找到的唯一可行的解决方案是改变填充,以便将 V 形“推”到侧面,但这是一个糟糕的解决方案,因为“ResultCard”视图会显得不稳定/关闭-以不同的显示尺寸为中心。
也许无法删除 V 形 - 如果是这种情况,是否有其他方法可以允许用户点击“ResultCard”视图并进入新页面,而不是通过导航关联?
我正在用头撞墙,所以非常感谢任何想法。
我对反应还很陌生,一个简单的老虎机是我的第一个迷你项目。目前我已经完成了按下按钮后显示随机表情符号的逻辑。对我来说,下一步是在设计和添加获胜/失败的逻辑以及硬币计数器等之前添加动画。
https://codepen.io/fmressel/pen/vRLerN
这个codepen正是我想要的东西,但正如你所看到的,它的结构与我的代码(如下)完全不同,我正在抓紧时间试图找出如何获得类似的东西来工作对于我的项目。
非常感谢任何帮助!
import React, { Component } from 'react'
import Contents from './Contents'
import './mainslots.css'
class Slots extends Component {
static defaultProps = {
fruits: ["", "", "", "", "", ""]
};
constructor(props) {
super(props);
this.state = {fruit1: '', fruit2: '', fruit3: '', rolling: false};
this.roll = this.roll.bind(this);
};
roll = () => {
const dFruit1 = this.props.fruits[
Math.floor(Math.random() * this.props.fruits.length)
];
const dFruit2 = this.props.fruits[
Math.floor(Math.random() * this.props.fruits.length)
];
const dFruit3 = this.props.fruits[
Math.floor(Math.random() * this.props.fruits.length)
]; …Run Code Online (Sandbox Code Playgroud)