Leisure Moment

乱花渐欲迷人眼,浅草才能没马蹄。最爱湖东行不足,绿杨阴里白沙堤。


  • Home

  • Archives

  • Tags

  • About

  • Sitemap

vue笔记

Posted on 2019-04-11
  1. $代表vue暴露的实力属性与方法
  2. @ 代表v-on 添建callback :代表v-bind添加双向绑定
  3. computed基于依赖缓存和methods则不是
  4. 当computed需要定制的时候采用watch选项
  5. data必须是一个函数,否则同类组件将共享状态
  6. 插槽用来向子组件传递内容

content-type 与spring boot 控制器的值注入关系

Posted on 2019-04-11

content-type = ‘application/x-www-form-urlencoded’ (不支持@RequestBody annotation)

前端传值template string为如下形式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
var http = new XMLHttpRequest();
var url = 'get_data.php';
var params = 'orem=ipsum&name=binny';
http.open('POST', url, true);

//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);

var params = ‘orem=ipsum&name=binny’;

content-type = ‘application/json’ (支持@RequestBody annotation)

1
2
3
4
5
6
7
8
9
let request = new XMLHttpRequest()
let url = "http://localhost:8080/user/regist";
request.open("POST", url, true)
request.setRequestHeader('Content-type','application/json; charset=utf-8');
let formData = {'userName=' + user.value + '&' + 'password=' + passwd.value};
formData.userName = user.value
formData.password = passwd.value
console.log(JSON.stringify(formData))
request.send(formData)

组件状态管理

Posted on 2019-04-11

何谓组件和容器

  1. 一个组件可以理解为UI重用的最小单位,它应该与业务逻辑不相关。
    可以理解纯组件,它的表现形式只有prop参数决定。 一旦其完成构造,应该是不可变的。

  2. 一个容器可以理解为UI状态管理的最小单位, 它与业务逻辑息息相关。
    可以理解管理组件的组件。

  3. GUI 应用应该由一个个组件像搭积木形成的一个个容器构成

无状态管理 (MV)

1
2
3
updateUI ( model -> UI)  // load

updateModel ( UI -> model) // save

UI.control.addListener(e-> updateModel())

UI状态维护困难,UI难以复用。

Binding机制view model (MVVM)

view与view model 双向绑定(data-binding):View的变动,自动反映在 ViewModel

  1. 定义domain 均为property

  2. view 与 viewModel 双向绑定

  3. view的变动仅反映在view model上(具体表现为property的变化),不需要通知其他view

  4. 只有在通过property 达不到的情况下才使用event bus.

  5. 双向绑定基于弱引用,Binding对象不会保持有双方的强引用,只有两个对象的弱引用
    你变我也变,我变你也变

  6. A单向bind B, 实际上是监听源B 对象添加一个监听器,该监听器强引用A,当B变化时,通知监听者A

故这里需要使用weak Listener, 防止由于data长期不销毁而导致view不销毁。

java fx中一切变化皆表现为property的变化

组件间通信

  1. 通过相互领域模型的bind

  2. event bus

父子组件通信

  1. scene graph 上节点

  2. event bus

旁系组件通信

  1. event bus
123…8
zhong-wei

zhong-wei

23 posts
3 categories
7 tags
RSS
© 2016 - 2019 zhong-wei