Skip to content

Conversation

@18911003097
Copy link

1

1
1
@hunshcn hunshcn self-requested a review January 19, 2021 06:30
Copy link
Contributor

@hunshcn hunshcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

写的不错,代码质量挺高,样式有比较大的提升空间

this.result=this.result*num
}else if(fun=="/"){
this.result=this.result/num
}else if(fun=="%"){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%的逻辑与其他不一致,需要单独拎出来。两次的原因是当你第一次点击%的时候,你的fun是上上次操作,而不是%。要在这超长的if前对targetvalue进行判断。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯嗯我改好了

<view hover-class="bg" hover-start-time="50" hover-stay-time="100" bindtap="potButton">.</view>
<view hover-class="bg" hover-start-time="50" hover-stay-time="100" bindtap="funButton"data-value="=">=</view>
</view>
</view>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复用函数的思想很不错,节省了很多代码,像这种全都是.bg的,你可以在父元素加class,用.bg view的选择器来选择,省的写那么多class

<view id="totality">
<view id="result">
<view id="num">{{num}}</view>
<view id="fun">{{fun}}</view>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果不需要显示直接不写这行就行了....

其实运算符可以在左边显示出来,也比较易用

隐藏比如display:none; height:0; width:0; font-size:0; color:transparent; visiablity:hidden都可以

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原来可以不写……受教了

.bg{ /*hover-class的颜色*/
background: rgb(179, 177, 177);
}

No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

样式......还行但不是特别好看,简单来讲可以缩小字体宽松布局

然后还可以看情况加上按钮背景颜色和边框

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy that~小米的计算器没加按钮颜色和边框(理直气壮

position: relative;
}

#num{ /*结果*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结果有一个bug,比如1/3这种无限小数,由于没做位数限制,会把屏幕占满,0.333333333只会显示出来33333,
可以在结果那边加上一个简单判断

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

@hunshcn hunshcn closed this Jan 19, 2021
<view>
<view hover-class="bg" hover-start-time="50" hover-stay-time="100" bindtap="resetButton">AC</view>
<view hover-class="bg" hover-start-time="50" hover-stay-time="100" bindtap="DELButton">DEL</view>
<view hover-class="bg" hover-start-time="50" hover-stay-time="100" bindtap="funButton" data-value="%">%</view>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace "funButton" with"perButton"

@hunshcn hunshcn reopened this Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants