nvue
html
<SurfaceView :style="viewStyle"></SurfaceView>
<button @click="add">变大</button>
javascript
export default {
data() {
return {
nums: 1
}
},
computed: {
viewStyle() {
if(this.nums === 1) {
return {height: "200upx",width: "750upx"}
}else {
return {height: "400upx",width: "750upx"}
}
}
},
methods: {
add() {
this.nums += 1
}
}
}
objective-c
surfaceview.h
#import <Foundation/Foundation.h>
#import "WeexSDK.h"
@interface SurfaceView : WXComponent
@end
surfaceview.m
#import "SurfaceView.h"
#import "TestNative.h"
@interface SurfaceView ()
@property (nonatomic, assign) NSInteger local;
@property (nonatomic, copy) NSString *identifyID;
@property (nonatomic, copy) NSString *trackID;
@property (nonatomic, copy) NSString *userID;
@end
@implementation SurfaceView
- (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance {
return self;
}
// 重制样式
- (void)updateStyles:(NSDictionary *)styles {
NSLog(@"updateStyles");
}
// 视图加载生命周期
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:30/255.0 green:30/255.0 blue:30/255.0 alpha:1.0];
[self setupPreviewView];
}
// 创建渲染视图
- (void)setupPreviewView {
[TestNativePlugin play:self.view];
}
@end
7***@qq.com (作者)
该问题已解决了
2022-06-13 14:36