下面是我的聚合物元素的代码我尝试了正常的dom绑定,一切正常
然而,img的src不起作用.我检查了chrome dev工具中的html,它显示src都错了
这里的src说是/img/12.jpg,这意味着图像在html文件所在的文件夹中然而它指的是文件夹的根目录
开发工具中预期的src:http:// localhost:3000/elements/image-hover/img/12.jpg
观察到src:img/12.jpg
我能做些什么才能将它编入预期的src?
<dom-module id="image-hover">
<template>
<img src="{{imgsrc}}"/>
</template>
</dom-module>
<script>
(function() {
Polymer({
is: 'image-hover',
properties: {
imgsrc: {
type: String,
value: 'img/12.jpg'
}
}
});
})();
</script>
Run Code Online (Sandbox Code Playgroud)
编辑:我已经通过使用聚合物提供的内容标签解决了这个问题.
<content id="image" select="img"></content>
Run Code Online (Sandbox Code Playgroud)
问题仍然是如何找出元素所在文件夹的来源.