javascript - 使用angular給圖片動態賦值src屬性出現unsafe的情況
問題描述
百度過后,在appmodule中設置了app.config的值 $compileProvider.imgSrcSanitizationWhitelist(/^s*(https?|local|data):/);但是沒有效果
想問一下大家還有什么其他辦法能去掉這個unsafe
html代碼: <p class='user_pic'><img src='http://m.4tl426be.cn/wenda/{{item.UserID | imgSrc}}' height='178px;'></p>controller中:app.filter(’imgSrc’, function () {
return function (input) {var src = ’’;if (input == undefined) { return;}$.ajax({ url: BaseURL + '/MainUser/LoadUserPersonalHomepageByUseriD?userID=' + input, type: ’get’, async: false, success: function (data) {if (data.UploadIMG == null) { src = ’/img/tp.png’} else { src = data.UploadIMG} }})return src; }});
問題解答
回答1:https://stackoverflow.com/que...
相關文章:
1. 對mysql某個字段監控的功能2. showpassword里的this 是什么意思?代表哪個元素3. html - vue項目中用到了elementUI問題4. JavaScript事件5. python - 為什么正常輸出中文沒有亂碼,zip函數之后出現中文編程unicode編碼的問題,我是遍歷輸出的啊。6. python - 使用readlines()方法讀取文件內容后,再用for循環遍歷文件與變量匹配時出現疑難?7. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能8. javascript - js中向下取整9. javascript - HTML字符串排版10. html5 - ElementUI table中el-table-column怎么設置百分比顯示。
