gpt4 book ai didi

javascript - 如何绑定(bind)到 Aurelia 中的编码图像?

转载 作者:行者123 更新时间:2023-11-30 11:58:07 25 4
gpt4 key购买 nike

src.bind 到 JSON 中的 ThumbNailPhoto

{
"@odata.context": "http://localhost:35027/odata/AdventureWorks/$metadata#Products",
"value": [
{
"ProductID": 714,
"Name": "Long-Sleeve Logo Jersey, M",
"ProductNumber": "LJ-0192-M",
"Color": "Multi",
"StandardCost": 38.4923,
"ListPrice": 49.99,
"Size": "M",
"Weight": null,
"ProductCategoryID": 25,
"ProductModelID": 11,
"SellStartDate": "2001-07-01",
"SellEndDate": null,
"DiscontinuedDate": null,
"ThumbNailPhoto": "R0lGODlhUAAyAPcAABQlZ/z8/J+fnyxLZ87OzuTk5Dtliqqqqiw0WMrKyvDw8EdXpRAYLsbGxubm5urq6qSkpO7u7uLi4mlmZa+vrxAhNiJai4iVqtLQ5rGxsY2v0zMzNfr6+i5zsiVLcmNwmLK8yHZ1esLCwhhHnfb29lB1rDIWcBdQofj4+H6OnfT09Li4tx07iCYlJt7e3qeotNra2o2NjTRcqCM0dQw2WxpTiCk0ZyxDXs/Q0BZkqvLy8hZamBlIhUWBt4enxVNLRpGRkRE/a1NXdRszlN3d3bS0tNfX15qamTI0PT4+PhYYHRkuWVdUUjE0Rw8aSCRUf9TU1GmGpn2lzIeCfsfG2RdhqVdPSkxcg5WVlMzR2Bk/maWhnKyppk5IRCxYmgUGCFBjfNDQziYuY5qYlpKNiRgpQpKOnx5RmTJqnCgtOOHg30U8OKGhoWdbd6iop5WUkjV5tUlCPTlaiM3Ny+Xk4nVzcLa2ttPT0i06SpeWlYyJhrq2sx88WLq6ur+9uqyxvcC+u+fm5NjY2HN9urGtqTlDet/f3zpMlicvSIuHhNXV0mBZVMrJxiw/VNDOy+no5z0nary6uLa0sLOxr6ysqwwqVAULFry9vdTS0MjHx+/v716VxRlenxgwgQwSHdvZ1+7u7Ovr6+Hh4drZ2WhiXk86dpm82htJkn54cw8PD7+/v/7+/r6+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Zc4A3JZROXGdUlLtixDUdsoZMAHCkCKkApWqC0CiUgBwhBmY4+vtQK1RgDIH4WNN1lT39GO1oAiBEIRqCig3ywABIQgAganDSdO0hF+EDpyjjAlBR6mGgBHtCxC15Rh9byZh4s0UZLPGGsHmDg1VBaCfAt9YFO6MIPFoGKcQBDDdyARV1vms+sjmwaOoDGFwDwvzLsox4DaAQY1mHUU3qhDEoD4TO/cM4uWGECZIjEKLyBqmj/2bGyNloFCrThjyE44X/pQAAYXuCDwZ6yBH+4gfCC4I8v1CAHWngHY83BCAnAQlC2tSRGLTuyACggHQRkgD9aEINuwOGsR+zBJayRC75GQU1aQMIEpsAFRzjAFZ6xKgaxiChcqGAfBLTFBP5QgoOmswr9yAIE9mEPDaipE6moAxkIEYb75teu2szlXHBBggk4AW9UWAAZjzqnHpyBdTmowD6m8IY+WThV2sXqg/6x0xB8WIgGTub6duCPaujhCM64w4uzu7vtzngVHMiAJQpYVBIr0ME02IAeYiCASxihFRG4MGWN/CAkF2HJOG7ygZfnYEtMIAZvcINjQpFlGBdZ/8Zd5mdvw4xewfHgHlEIQipiEIMjUK8A+NXyReFsowDoIBVyA+MNDMBoHnLRjS1oQTpIEQMg1E4QrbCSoG/L5UITYwWkYEI7qgEEILzhDXnAwqlLzWpW87nSAigCMEQBCwUARmhvzuCMd1qLaNiBDanOQx7GMIYjHKHYxk62sgXAhgw0AAaZfpF+77pNL3FAAS7IhB0o4QY3cCEblCAEJShA7nJn4NwZKIIdLpEAKrZI2hjGKXdREwASwMIQd3hJJhgBDGDMwREEwIHAcRCNaNzh4HdABwxEgWV4HOjW085wTjU4DRJoohZVtN8jjnGMVqTt4yCvxbNaVKCHbzrG+0CigCpWzvKWu/zlK7/EJfqwgprzog84z7nOb86Lnvu8Dz7nRc3tYAdnFKEIGSg3JShxgG5DAAJsEICxx4CFUgcEADs=",
"ThumbnailPhotoFileName": "awc_jersey_male_small.gif",
"rowguid": "6a290063-a0cf-432a-8110-2ea0fda14308",
"ModifiedDate": "2004-03-11"
}
]
}

最佳答案

您可以通过以下三种方式做到这一点:

https://gist.run?id=e4d55a8a596bcf9d480c92ec22825597

app.html

<template>
<require from="./data-uri-value-converter"></require>

<h3>binding expression</h3>
<img src.bind="'data:image/gif;base64,' + data.value[0].ThumbNailPhoto">

<h3>string interpolation binding expression</h3>
<img src="data:image/gif;base64,${data.value[0].ThumbNailPhoto}">

<h3>value converter binding expression</h3>
<img src.bind="data.value[0].ThumbNailPhoto | dataUri:'image/gif'">
</template>

app.js

export class App {
data = {
"@odata.context": "http://localhost:35027/odata/AdventureWorks/$metadata#Products",
"value": [
{
"ProductID": 714,
"Name": "Long-Sleeve Logo Jersey, M",
"ProductNumber": "LJ-0192-M",
"Color": "Multi",
"StandardCost": 38.4923,
"ListPrice": 49.99,
"Size": "M",
"Weight": null,
"ProductCategoryID": 25,
"ProductModelID": 11,
"SellStartDate": "2001-07-01",
"SellEndDate": null,
"DiscontinuedDate": null,
"ThumbNailPhoto": "R0lGODlhUAAyAPcAABQlZ/z8/J+fnyxLZ87OzuTk5Dtliqqqqiw0WMrKyvDw8EdXpRAYLsbGxubm5urq6qSkpO7u7uLi4mlmZa+vrxAhNiJai4iVqtLQ5rGxsY2v0zMzNfr6+i5zsiVLcmNwmLK8yHZ1esLCwhhHnfb29lB1rDIWcBdQofj4+H6OnfT09Li4tx07iCYlJt7e3qeotNra2o2NjTRcqCM0dQw2WxpTiCk0ZyxDXs/Q0BZkqvLy8hZamBlIhUWBt4enxVNLRpGRkRE/a1NXdRszlN3d3bS0tNfX15qamTI0PT4+PhYYHRkuWVdUUjE0Rw8aSCRUf9TU1GmGpn2lzIeCfsfG2RdhqVdPSkxcg5WVlMzR2Bk/maWhnKyppk5IRCxYmgUGCFBjfNDQziYuY5qYlpKNiRgpQpKOnx5RmTJqnCgtOOHg30U8OKGhoWdbd6iop5WUkjV5tUlCPTlaiM3Ny+Xk4nVzcLa2ttPT0i06SpeWlYyJhrq2sx88WLq6ur+9uqyxvcC+u+fm5N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igCpWzvKWu/zlK7/EJfqwgprzog84z7nOb86Lnvu8Dz7nRc3tYAdnFKEIGSg3JShxgG5DAAJsEICxx4CFUgcEADs=",
"ThumbnailPhotoFileName": "awc_jersey_male_small.gif",
"rowguid": "6a290063-a0cf-432a-8110-2ea0fda14308",
"ModifiedDate": "2004-03-11"
}
]
};
}

data-uri-value-converter.js

export class DataUriValueConverter {
toView(value, mimeType) {
return `data:${mimeType};base64,${value}`;
}
}

关于javascript - 如何绑定(bind)到 Aurelia 中的编码图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37360758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com