Vue templateUrl 扩展
2020-06-29 04:43
183 查看
/** * 扩展的 Vue 的 templateUrl 插件! * 虽然有点未被作者的初衷, 但是灵活才是第一偶觉得啊. * 这种方法是不支持, 单独的 $mount 的方式的. * * @author 拓荒者 <358279128@QQ.com> * @beta v1.0.0 */ Vue.use(function templateUrl(){ Vue.mixin({ beforeCreate: function _beforeCreate(){ if ( this.$options.render !== undefined || this.$options.template !== undefined || ( this.$options.templateUrl === undefined || typeof this.$options.templateUrl !== 'string' ) ) { return ; } var $scope = this; Vue.http.get(this.$options.templateUrl).then(function(response){ $scope.$options.render = Vue.compile(response.body).render; $scope.$mount($scope.$options.el); }); } }) });
转载于:https://my.oschina.net/CocoFather/blog/794474
相关文章推荐
- 【转】OpenGL版本与OpenGL扩展机制
- 支持库:Int32扩展
- VS2010添加Visual Assist 扩展
- mac ox 10.11 brew安装Nginx+PHP+MySQL+扩展
- Ext.js中自己扩展的EasyGrid
- 扩展欧几里得模板(洛谷1082 同余方程NOIP 2012 提高组 第二天 第一题)
- 扩展:关于ES字符串类型(Text vs keyword)的选择
- 系统之纵向扩展
- ORACLE SQL 扩展DML
- 扩展PHP,使用C库
- php安装curl扩展
- [翻译][php扩展开发和嵌入式]第0章-译序
- !analyze 扩展
- Centos下给php安装Redis扩展及编译问题解决
- 扩展欧几里得算法
- 【python学习笔记】24:scipy扩展库的安装与初识
- LVM 逻辑卷的创建与扩展
- NHibernate扩展方法(-) --NHibernateHelper
- php类的扩展和继承用法实例
- jQuery 扩展对input的一些操作方法