js更新属性:
<HMap v-if="mapshow" ref="hmap" style="width: 100%; height: 400rpx;" showcorver:"true" :markers="markcovers" :location="location"></HMap>
// 无论怎么改变covers或者下面的lat和long数据,都不会触发updateAttributes
computed: {
markcovers() {
console.log("computed markcovers")
return this.covers
},
location() {
console.log("computed location")
return {'latitude':this.latitude, 'longitude':this.longitude, 'zoom':this.scale};
}
}
OC中注册插件
<key>dcloud_uniplugins</key>
<array>
<dict>
<key>hooksClass</key>
<string></string>
<key>plugins</key>
<array>
<dict>
<key>class</key>
<string>HMapComponent</string>
<key>name</key>
<string>HMap</string>
<key>type</key>
<string>component</string>
</dict>
</array>
</dict>
</array>
实现代码:
@interface HMapComponent : DCUniComponent
@end
@interface HMapComponent()<HMapViewDelegate>
@end
@implementation HMapComponent
- (UIView *)loadView {
self.mapView = [HMapView new];
return self.mapView;
}
- (void)onCreateComponentWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events uniInstance:(DCUniSDKInstance *)uniInstance {
NSLog(@"onCreateComponentWithRef attributes:%@", attributes);
}
- (void)updateStyles:(NSDictionary *)styles {
NSLog(@"updateStyles styles:%@", styles);
}
/// 前端更新属性回调方法
/// @param attributes 更新的属性
- (void)updateAttributes:(NSDictionary *)attributes {
}
0 个回复