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. vue router 如何使用params query传参,以及有什么区别

    写在前面: 传参是前端经常需要用的一个操作,很多场景都会需要用到上个页面的参数,本文将会详细介绍vue router 是如何进行传参的,以及一些小细节问题.有需要的朋友可以做一下参考,喜欢的可以点波赞 ...

  2. shiro的web.xml的配置

    <servlet> <servlet-name>springDispatcherServlet</servlet-name> <servlet-class&g ...

  3. 解决Cannot change version of project facet Dynamic Web Module to 3.1

    Open web.xml from project structure http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version= ...

  4. SQLite 数据类型与C#数据类型对应表

        SQLite 数据类型 C# 数据类型   BIGINT Int64   BIGUINT UInt64   BINARY Binary   BIT Boolean 首选 BLOB Binary ...

  5. SparseArray II

    SparseArray: SparseArray是android里为<Interger,Object>这样的Hashmap而专门写的类,目的是提高内存效率,其核心是折半查找函数(binar ...

  6. leetcode-easy-string-344 Reverse String

    mycode class Solution(object): def reverseString(self, s): """ :type s: List[str] :rt ...

  7. SQL Server2016 AlwaysOn无域高可用

    https://blog.csdn.net/qq_41981651/article/details/90314817 https://blog.csdn.net/roven257/article/de ...

  8. Python2.x与Python3.x的主要区别(转)

    python2.x和python3.x版本有很大的差异,除了依赖包的名称变化很大外,其主要差异总结如下: 1)print函数 Python3中,print函数的括号是必须的,Python2是可选的. ...

  9. C++重写实践&与java的差异

    C++重写父类方法后,父类中同名的方法在子类中就无法被调用,回报这个问题: java中是没有这个问题的,显然java设计者在设计的时候有意解决了这个问题. C++实践代码: #include < ...

  10. 图片存进Mat类中,然后调用图像矩阵元素

    Mat img = imread();//灰度图 imwrite("origin.png",img); if(img.empty()) { cout << " ...