kofwang
V2EX  ›  Angular

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

  •  
  •   kofwang · Jul 15, 2015 · 8739 views
    This topic created in 4141 days ago, the information mentioned may be changed or developed.

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

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

    请教高手,如何破?

    5 replies  •  2015-07-30 12:57:54 +08:00
    chairuosen
    chairuosen
    Jul 15, 2015
    1
    去仔细看ng-src文档
    kofwang
    kofwang
    OP
    Jul 15, 2015
    2
    问题有点笔误,重新修改一下:

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

    $scope.my_avatar = $sce.trustAsResourceUrl('wxLocalResource://45862098790874');
    juneszh
    juneszh
    Jul 27, 2015
    4
    @dagger 你好,使用你的方法不行啊, $sce.trustAsResourceUrl('weixin://resourceid/418c789f7859a09d2048b1aaad59acb6') 不生效
    dagger
    dagger
    Jul 30, 2015
    5
    @juneszh 有没有报错信息?angular-sanitize.js有没有加载?controller有没有引入$sce?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1897 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 07:16 · PVG 15:16 · LAX 23:16 · JFK 02:16
    ♥ Do have faith in what you're doing.