如何在脚本的导出部分和未导出的部分之间传递值?
结构如下:
<script>
// PART 1:
import { EventBus } from './event-bus.js';
EventBus.$on('value-received', value => {
this.receivedValue = value;
});
// PART 2:
export default {
data() {
return {
receivedValue: ''
}
},
watch: {...},
methods: {...}
}
</script>
如何将value
分配给receivedValue
变量并使其可用于Vue方法?
答案 0 :(得分:1)
由于您的EventBus.$on
调用使用了箭头功能,因此this
引用的this
是EventBus
调用时范围内的receivedValue
。
如果您对事件的所有实例都具有相同的var shared = { receivedValue: '' };
EventBus.$on('value-received', value => {
shared.receivedValue = value;
});
export default {
data() { return shared; }
watch: ...,
methods: ....
}
感到满意,则可以将收到的值重定向到文件范围内的对象:
shared
Vue.js将注册一个处理程序来对您返回的对象的更改做出反应,即。 data()
。
如果出于某种原因,您希望每个组件实例都有一个单独的事件流,则需要在Sub Populate()
Dim Worksh As Worksheet
Dim Cell As Range
Set Worksh = Sheets("Serial Numbers")
customer = "EXELON"
'*********************** Populate Serial Number ********************
'*******************************************************************
JobTT = 10080
With Worksh.Range("E7")
.AutoFill .Resize(JobTT, 1), xlFillSeries
End With
With Worksh.Range("F7")
'.Value = cus_strt_num
.AutoFill .Resize(JobTT, 1), xlFillSeries
'Range("mycell").Select
Select Case customer
Case "EXELON"
For Each Cell In Range("mycell")
If Not IsEmpty(Cell) Then _
Cell = "DARG2" & Cell
Next Cell
Case "AEP"
For Each Cell In Range("mycell")
If Not IsEmpty(Cell) Then _
Cell = "1ND" & Cell & "NMD06"
Next Cell
End Select
End With
With Worksh.Range("D7")
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D127")
.Value = Worksh.Range("D126") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D247")
.Value = Worksh.Range("D146") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D367")
.Value = Worksh.Range("D366") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D487")
.Value = Worksh.Range("D486") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D607")
.Value = Worksh.Range("D606") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D727")
.Value = Worksh.Range("D726") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D847")
.Value = Worksh.Range("D846") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D967")
.Value = Worksh.Range("D966") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D1087")
.Value = Worksh.Range("D1086") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D1207")
.Value = Worksh.Range("D1206") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D1327")
.Value = Worksh.Range("D1326") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D1447")
.Value = Worksh.Range("D1446") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D1567")
.Value = Worksh.Range("D1566") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D1687")
.Value = Worksh.Range("D1686") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D1807")
.Value = Worksh.Range("D1806") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D1927")
.Value = Worksh.Range("D1926") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D2047")
.Value = Worksh.Range("D2046") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D2167")
.Value = Worksh.Range("D2166") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D2287")
.Value = Worksh.Range("D2286") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D2407")
.Value = Worksh.Range("D2406") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D2527")
.Value = Worksh.Range("D2526") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D2647")
.Value = Worksh.Range("D2646") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D2767")
.Value = Worksh.Range("D2766") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D2887")
.Value = Worksh.Range("D2886") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D3007")
.Value = Worksh.Range("D3006") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D3127")
.Value = Worksh.Range("D3126") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D3247")
.Value = Worksh.Range("D3246") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D3367")
.Value = Worksh.Range("D3366") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D3487")
.Value = Worksh.Range("D3486") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D3607")
.Value = Worksh.Range("D3606") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D3727")
.Value = Worksh.Range("D3726") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D3847")
.Value = Worksh.Range("D3846") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D3967")
.Value = Worksh.Range("D3966") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D4087")
.Value = Worksh.Range("D4086") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D4207")
.Value = Worksh.Range("D4206") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D4327")
.Value = Worksh.Range("D4326") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D4447")
.Value = Worksh.Range("D4446") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D4567")
.Value = Worksh.Range("D4566") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D4687")
.Value = Worksh.Range("D4686") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D4807")
.Value = Worksh.Range("D4806") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D4927")
.Value = Worksh.Range("D4926") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D5047")
.Value = Worksh.Range("D5046") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D5167")
.Value = Worksh.Range("D5166") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D5287")
.Value = Worksh.Range("D5286") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D5407")
.Value = Worksh.Range("D5406") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D5527")
.Value = Worksh.Range("D5526") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D5647")
.Value = Worksh.Range("D5646") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D5767")
.Value = Worksh.Range("D5766") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D5887")
.Value = Worksh.Range("D5886") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D6007")
.Value = Worksh.Range("D6006") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D6127")
.Value = Worksh.Range("D6126") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D6247")
.Value = Worksh.Range("D6246") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D6367")
.Value = Worksh.Range("D6366") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D6487")
.Value = Worksh.Range("D6486") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D6607")
.Value = Worksh.Range("D6606") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D6727")
.Value = Worksh.Range("D6726") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D6847")
.Value = Worksh.Range("D6846") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D6967")
.Value = Worksh.Range("D6966") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D7087")
.Value = Worksh.Range("D7086") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D7207")
.Value = Worksh.Range("D7206") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D7327")
.Value = Worksh.Range("D7326") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D7447")
.Value = Worksh.Range("D7446") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D7567")
.Value = Worksh.Range("D7566") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D7687")
.Value = Worksh.Range("D7686") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D7807")
.Value = Worksh.Range("D7806") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D7927")
.Value = Worksh.Range("D7926") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D8047")
.Value = Worksh.Range("D8046") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D8167")
.Value = Worksh.Range("D8166") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D8287")
.Value = Worksh.Range("D8286") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D8407")
.Value = Worksh.Range("D8406") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D8527")
.Value = Worksh.Range("D8526") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D8647")
.Value = Worksh.Range("D8646") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D8767")
.Value = Worksh.Range("D8766") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D8887")
.Value = Worksh.Range("D8886") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D9007")
.Value = Worksh.Range("D9006") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D9127")
.Value = Worksh.Range("D9126") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D9247")
.Value = Worksh.Range("D9246") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D9367")
.Value = Worksh.Range("D9366") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D9487")
.Value = Worksh.Range("D9486") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D9607")
.Value = Worksh.Range("D9606") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
With Worksh.Range("D9727")
.Value = Worksh.Range("D9726") + 1
.AutoFill .Resize(120, 1), xlFillValues
End With
End Sub
函数内创建一个新对象,并让事件总线直接更新新对象。