增加 when和which方法; 同时mounted回调时更新渲染
							parent
							
								
									065271f2f6
								
							
						
					
					
						commit
						0f09245657
					
				|  | @ -1,6 +1,6 @@ | ||||||
| { | { | ||||||
|   "name": "wkit", |   "name": "wkit", | ||||||
|   "version": "1.11.5", |   "version": "1.11.6", | ||||||
|   "type": "module", |   "type": "module", | ||||||
|   "description": "A library for building fast, lightweight web components.", |   "description": "A library for building fast, lightweight web components.", | ||||||
|   "main": "dist/index.js", |   "main": "dist/index.js", | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								src/index.js
								
								
								
								
							
							
						
						
									
										16
									
								
								src/index.js
								
								
								
								
							|  | @ -59,6 +59,21 @@ export function styleMap(data = {}) { | ||||||
|   return output |   return output | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // 三元运算符的函数封装(只为了省个参数)
 | ||||||
|  | export function when(condition, trueCase = '', falseCase = '') { | ||||||
|  |   return condition ? trueCase : falseCase | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // swicth语句的封装
 | ||||||
|  | export function which(target, list = [], defaultCase = '') { | ||||||
|  |   for (let [name, content] of list) { | ||||||
|  |     if (target === name) { | ||||||
|  |       return content | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return defaultCase | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export class Component extends HTMLElement { | export class Component extends HTMLElement { | ||||||
|   /** |   /** | ||||||
|    * 声明可监听变化的属性列表 |    * 声明可监听变化的属性列表 | ||||||
|  | @ -387,6 +402,7 @@ export class Component extends HTMLElement { | ||||||
|           this.activated() |           this.activated() | ||||||
|         } |         } | ||||||
|         this.mounted() |         this.mounted() | ||||||
|  |         this.$requestUpdate() | ||||||
|       }) |       }) | ||||||
|     } else { |     } else { | ||||||
|       nextTick(_ => this.updated(props)) |       nextTick(_ => this.updated(props)) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue