在uniapp中,0.05加上0.01不是应该等于0.06吗,为什么加起来会出现那么多的小数,网上找了一下问题,说是精度丢失问题,求解
// 商品金额
const altogether = 订单金额;
// 运费
const transport = 运费;
// 应付款
const total = (altogether + transport).toFixed(2)
全局事件监听
方法(这个很好用)C页面
:第一个参数是事件名,第二个是触发事件携带的附加参数uni.$emit('selectName','巴比伦')
B页面
:第一个参数是事件名,第二个是事件回调函数onShow() {
uni.$on('selectName',(res)=>{
console.log(res,'从C页面传递的数据')
})
}
$on
事件要在onShow()中写……在onLoad()中没反应vuex
中,在B页面内访问即可。this.$store.state.name='巴比伦'
vue项目使用router传参和route接收也是这种思想吧……