V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
kofwang
V2EX  ›  Angular

Angularjs 做微信 webapp 开发,显示图片的问题

  •  
  •   kofwang · 2015-07-15 11:15:52 +08:00 · 7151 次点击
    这是一个创建于 3179 天前的主题,其中的信息可能已经有所发展或是发生改变。

    通过微信Js sdk,调用拍照接口后,拿到图片的url为“wxLocalResource://45862098790874”

    我这样做:
    模板:<img ng-src="my_avatar">
    程序:$scope.my_avatar = “wxLocalResource://45862098790874”;
    图片无法显示啊!

    请教高手,如何破?

    5 条回复    2015-07-30 12:57:54 +08:00
    chairuosen
        1
    chairuosen  
       2015-07-15 11:27:19 +08:00
    去仔细看ng-src文档
    kofwang
        2
    kofwang  
    OP
       2015-07-15 11:33:35 +08:00
    问题有点笔误,重新修改一下:

    我这样做:
    模板:<img ng-src=“{{my_avatar}}”>
    程序:$scope.my_avatar = “wxLocalResource://45862098790874”;
    图片无法显示啊!
    dagger
        3
    dagger  
       2015-07-15 16:40:52 +08:00   ❤️ 1
    https://docs.angularjs.org/api/ng/service/$sce#trustAsResourceUrl

    $scope.my_avatar = $sce.trustAsResourceUrl('wxLocalResource://45862098790874');
    juneszh
        4
    juneszh  
       2015-07-27 11:05:15 +08:00
    @dagger 你好,使用你的方法不行啊, $sce.trustAsResourceUrl('weixin://resourceid/418c789f7859a09d2048b1aaad59acb6') 不生效
    dagger
        5
    dagger  
       2015-07-30 12:57:54 +08:00
    @juneszh 有没有报错信息?angular-sanitize.js有没有加载?controller有没有引入$sce?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3252 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 11:49 · PVG 19:49 · LAX 04:49 · JFK 07:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.