v-bind

v-bind  主要用于属性绑定,

html中的标签内:

        <div class="control-group">
<label class="control-label">封面图:</label> <div class="controls">
<input type="button" value="添加" onclick="BrowseServer('image',2)" />
<div id="app" class="box" style="width:100%">
<ul style="overflow:hidden;margin:10px;padding:2px;list-style:none;">
<li style="float:left;width:200px; height:200px; position:relative;" >
<input id="imgeConId" type="hidden" name="pic" v-bind:value="v_pic" />
<img v-bind:src="i_img" alt="" style="position:absolute;left:0;top:0;bottom:0;right:0;max-width:200px;max-height:200px">
</li>
</ul>
</div>
</div> </div>

js的代码:

var bannerPic='${hmlwxItinerantExhibition.bannerPic}';
var im = '${ctn}'+'${hmlwxItinerantExhibition.pic}';
var pic = '${hmlwxItinerantExhibition.pic}';
if(bannerPic && bannerPic!=''){
bannerPic=$.parseJSON(bannerPic);
}else{
bannerPic=[];
} window.app=new Vue({
el:"body",
data:{
v_picList:bannerPic,
v_pic:pic,
i_img:im
},
watch:{ },
ready:function(){
var size = this.v_picList.length;
var newArray=[];
var c=0;
for(var i=0;i<size;i++){
var reg='^'+'${ctn}'+'\\S*';
if(this.v_picList[i].match(reg)){
newArray[c++]=this.v_picList[i];
}else{
newArray[c++]='${ctn}'+this.v_picList[i];
}
}
this.v_picList=newArray;
window.app=this;
},
methods:{
imgDbClick:function(data){
var size=window.app.v_picList.length;
var newArray=[];
var c=0;
for(var i=0;i<size;i++){
if(i!=data){
newArray[c++]=window.app.v_picList[i];
}
}
window.app.v_picList=newArray;
} }
});
}); function BrowseServer(inputId,type){
var finder = new CKFinder() ;
finder.basePath = '${ctx}/static/ckfinder/'; //导入CKFinder的路径
if(type == 1){
finder.selectActionFunction = SetFileField; //多张
}
else if(type == 2 ){
finder.selectActionFunction = setPic; //单张
}
finder.selectActionData = inputId; //接收地址的input ID
finder.popup() ;
};
//文件选中时执行
function SetFileField(fileUrl,data)
{
window.app.v_picList.push(fileUrl); }
//封面
function setPic(fileUrl,data){
var patt2 = new RegExp(".jpeg|.jpg|.bng|.gif","g");
if(!patt2.exec(fileUrl)){
top.$.jBox.alert("请选择图片类型数据");
return;
} var NfileUrl = fileUrl.substring(fileUrl.indexOf('/',fileUrl.indexOf('/')+1));
window.app.v_pic=NfileUrl;
window.app.i_img=fileUrl; }

简单例子:

     <div class="control-group">
<label class="control-label">详细分类缩略图:</label>
<%-- <div class="controls">
<form:input path="classificationPic" htmlEscape="false" maxlength="100" class="input-xlarge "/>
</div> --%>
<div class="controls">
<input type="button" value="添加" onclick="BrowseServer('image')" />
<div id="app" class="box" style="width:100%">
<ul style="overflow:hidden;margin:10px;padding:2px;list-style:none;">
<li style="float:left;width:200px; height:200px; position:relative;" >
<input id="imgeConId" type="hidden" name="classificationPic" v-bind:value="classificationPic" />
<img v-bind:src="img" alt="" style="position:absolute;left:0;top:0;bottom:0;right:0;max-width:200px;max-height:200px">
</li>
</ul>
</div>
</div>

js的代码:

            var s = '${ctn}'+'${hmlwxClassification.classificationPic}'; 
window.app = new Vue({
el: '#app',
data: {
classificationPic:s,
img:s
}
});

//文件选中时执行
function SetFileField(fileUrl,data)
{
var NfileUrl = fileUrl.substring(fileUrl.indexOf('/',fileUrl.indexOf('/')+1));
window.app.classificationPic=NfileUrl;
window.app.img=fileUrl;

}

vue.js的v-bind的更多相关文章

  1. Vue.js的从入门到放弃进击录(一)

    感谢我们项目组给机会,让我学了Vue.js,打开新世界大门...哈哈哈,也没有那么夸张,不过学下来确实觉得入门还是蛮容易的.我大概前前后后学了有一个月的样子,一开始只是比较急着可以写东西出来,后来因为 ...

  2. 01.什么是Vue.js

    VUE.JS 什么是Vue.js Vue.js 是目前最火的一个前端框架,React是最流行的一个前端框架(React除了开发网站,还可以开发手机App, Vue语法也是可以用于进行手机App开发的, ...

  3. 02: vue.js常用指令

    目录:Vue其他篇 01: vue.js安装 02: vue.js常用指令 目录: 1.1 vuejs简介 1.2 选择器:根据id.class等查找 1.3 静态绑定数据 data 1.4 插值 { ...

  4. .Vue.js大全

    Vue起步 1.下载核心库vue.js bower info vue npm init --yes cnpm install vue --save vue2.0和1.0相比,最大的变化就是引入了Vir ...

  5. Vue.js - Day1

    什么是Vue.js Vue.js 是目前最火的一个前端框架,React是最流行的一个前端框架(React除了开发网站,还可以开发手机App, Vue语法也是可以用于进行手机App开发的,需要借助于We ...

  6. web前端开发面试题(Vue.js)

    1.active-class是哪个组件的属性?嵌套路由怎么定义? 答:vue-router模块的router-link组件. 2.怎么定义vue-router的动态路由?怎么获取传过来的动态参数?  ...

  7. Vue.js 源码分析(二十八) 高级应用 transition组件 详解

    transition组件可以给任何元素和组件添加进入/离开过渡,但只能给单个组件实行过渡效果(多个元素可以用transition-group组件,下一节再讲),调用该内置组件时,可以传入如下特性: n ...

  8. vue.js中英文api

    全局配置 Vue.config is an object containing Vue's global configurations. You can modify its properties l ...

  9. MVVM大比拼之vue.js源码精析

    VUE 源码分析 简介 Vue 是 MVVM 框架中的新贵,如果我没记错的话作者应该毕业不久,现在在google.vue 如作者自己所说,在api设计上受到了很多来自knockout.angularj ...

  10. MVC、MVP、MVVM、Angular.js、Knockout.js、Backbone.js、React.js、Ember.js、Avalon.js、Vue.js 概念摘录

    注:文章内容都是摘录性文字,自己阅读的一些笔记,方便日后查看. MVC MVC(Model-View-Controller),M 是指业务模型,V 是指用户界面,C 则是控制器,使用 MVC 的目的是 ...

随机推荐

  1. JSON格式标准

    JSON格式 json的基本类型有objects(dicts), arrays(lists), strings, numbers, booleans, and nulls(json中关键字).在一个o ...

  2. sublime text3 最新 license注册码分享 2018

    —– BEGIN LICENSE —– Die Socialisten GmbH 10 User License EA7E-800613 51311422 E45F49ED 3F0ADE0C E5B8 ...

  3. C++入门经典-例6.5-连接字符串

    1:运行代码如下: // 6.5.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> usin ...

  4. C++入门经典-例3.24-找图书的位置

    1:运行代码: // 3.24.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> usin ...

  5. Java线程细节

    启动一个线程是用  run() 还是 start()?启动一个线程是调用 start()方法,启动线程并调用 run 方法 线程的基本概念.线程的基本状态以及状态之间的关系线程是进程内的并发,没有自已 ...

  6. vue开发多页面应用

    1.添加多页面配置 在工程根路径下(package.json同目录)添加添加vue.config.js配置文件,内容为: module.exports = { pages: { index: 'src ...

  7. Watir单元库

    http://www.cnblogs.com/Javame/p/4045229.html test: #require 'net/http' #require 'uri' #url = URI.par ...

  8. Electron对JQuery的支持问题

    最近在了解Electron框架写应用,偶然发现在html中使用<script src="./jquery.js"></script>这种方式引入JQuery ...

  9. leetcode 172. Factorial Trailing Zeroes(阶乘的末尾有多少个0)

    数字的末尾为0实际上就是乘以了10,20.30.40其实本质上都是10,只不过是10的倍数.10只能通过2*5来获得,但是2的个数众多,用作判断不准确. 以20的阶乘为例子,造成末尾为0的数字其实就是 ...

  10. iOS charts CombinedChartView First and last bars are shown half only

    charts 使用CombinedChartView 绘图时,发现第一个和最后一个bar只能显示一半的问题,解决方法: ChartXAxis *xAxis = chartView.xAxis; xAx ...