table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title:'商品编号'},
{field: 'fid', title: '主站编号'},
{field: 'name', title: __('Name')},
{field: 'is_out', title: '商品状态',formatter:function(value,row,index){
if(value==1){
return '<a style="text-decoration:none;color:#18bc9c" data-id='+row.id+' class="sold_out" href="javascript:void(0);">已上架</a> '
}else{
// return '<a style="text-decoration:none;color:gray" data-id='+row.id+' class= "sold_up" href="javascript:void(0);">已下架</a>'
return '<a href="#" onclick=response()>测试</a>'
}
}},
{field: 'price', title: __('Price'), operate:'BETWEEN'},
{field: 'weight', title: __('Weight'), operate:'BETWEEN'},
{field: 'goods_image', title: __('Goods_image'), formatter: Table.api.formatter.image},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate},
]
]
});
function response(){
alert('hello world')
}
//我明明定义了这个response函数 为什么还会报response未定义的错误 有没有大神帮忙解答一下![图片描述][1]
自己来回答 该问题已解决
第一种解决方式 通过全局对象window把给函数全局曝光
第二种解决方式 在table初始化外面定义