node-web-mvc
Version:
node spring mvc
47 lines (46 loc) • 1.05 kB
JavaScript
"use strict";
/**
* @module ModelAndView
* @description 数据视图类,返回此结果,最终会使用指定模板来返回html内容
*/
Object.defineProperty(exports, "__esModule", { value: true });
class ModelAndView {
/**
* 判断当前模型数据是否为空
*/
isEmpty() {
return !this.view && !this.model;
}
/**
* 判断当前模型是否已清空
*/
wasCleared() {
return this.cleared && this.isEmpty;
}
/**
* 数据视图实例
* @param view 视图名称
* @param model 视图数据
*/
constructor(view, model, status) {
this.view = view;
this.status = status;
this.model = model;
}
/**
* 清空实例数据
*/
clear() {
this.cleared = true;
this.view = null;
this.model = null;
}
/**
* 添加一个属性到model中去
*/
addObject(name, data) {
this.model = this.model || {};
this.model[name] = data;
}
}
exports.default = ModelAndView;