VueSwif 2.0发布啦

6 篇文章 0 订阅
4 篇文章 0 订阅

VueSwift 是轻量级IOC(控制反转),MVVM,面向接口编程动态组件框架,快捷方便,不侵入兼容老项目。

实例:

let arrayId = “arrayId” //定义数据ID
let indexId = “indexId” //定义事件ID

class MainVC: UIViewController {

var m:Vue?   //IOC/DI
override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    self.view.backgroundColor = UIColor.white

//注册组件,cellModel 对应 Cell
Vue.register(aClass: MainModel.classForCoder(), toClass: MainCell.classForCoder())
Vue.register(aClass: TextModel.classForCoder(), toClass: TextCell.classForCoder())
Vue.register(aClass: ButtonModel.classForCoder(), toClass: ButtonCell.classForCoder())
Vue.register(aClass: FieldModel.classForCoder(), toClass: FieldCell.classForCoder())
//容器,动态组件加载器
let table = CTable()
table.rowHeight = 60
self.view.addSubview(table)
table.snp.makeConstraints { (make) in
make.top.equalTo(64)
make.left.equalTo(0)
make.right.equalTo(0)
make.bottom.equalTo(0)

    }
  //绑定ID
    table.v_array(vId: arrayId, vue: m)
    table.v_index(vId: indexId, vue: m)
  
    m?.v_start()
}

}

//model类
class Main:Vue,V_ViewControllerProtocol{

//VC协议
func v_viewController() -> UIViewController {

    let vc = MainVC()
    vc.m = self
    vc.navigationItem.title = "列表"
    return vc
}
override func v_start() {
    
    let list = ["lable","button","textField"]
    var array = Array<VueData>()
    for value in list{
        
        let m = MainModel()
        m.name = value
        array.append(m)
        
    }

//数据ID
self.v_array(vId: arrayId) { () -> Array? in

        return array
    }

//事件ID
self.v_index(vId: indexId) { (index) in
switch index{ //路由 接受model
case 0:Router.push(Text(), [“id”:10], nil)
case 1:Router.push(Button(), [“id”:10], nil)
case 2:Router.push(Field(), [“id”:10], nil)
default:print(“kong”)
}
}

}

}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值