相关疑难解决方法(0)

为什么在AngularJS指令中不推荐使用`replace`属性?

根据API文档,指令的replace属性已被弃用,因此将来所有指令都将使用当前默认值replace: false.

这消除了开发人员替换元素指令元素的能力,但没有明显替代此功能.

有关元素指令如何使用和不使用的示例,请参阅此plunkreplace: true.

为什么这个有用的属性被弃用而没有替换?

javascript angularjs angularjs-directive

108
推荐指数
4
解决办法
6万
查看次数

删除由角度组件创建的主机HTML元素选择器

在角度2中,svg-rect是一个创建rect的组件,如下所示,

<svg height="550" width="450" x="0" y="0">
    <g id="svgGroup">
        <svg-rect>
        <!--template bindings={}-->
            <rect x="10" y="10" height="100" width="100" fill="red" stroke="#000" stroke-width="2"></rect>
        <!--template bindings={}-->
        </svg-rect>
        <svg-rect>
        <!--template bindings={}-->
            <rect x="10" y="10" height="100" width="100" fill="red" stroke="#000" stroke-width="2"></rect>
        <!--template bindings={}-->
        </svg-rect>
    </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

但由于创建了特殊元素标签,因此不会呈现rect.如果删除了svg-rect标签,则会呈现rect

<svg height="550" width="450" x="0" y="0">
    <g id="svgGroup">
        <!--template bindings={}-->
        <rect x="10" y="10" height="100" width="100" fill="red" stroke="#000" stroke-width="2"></rect>
        <!--template bindings={}-->
        <!--template bindings={}-->
        <rect x="10" y="10" height="100" width="100" fill="red" stroke="#000" stroke-width="2"></rect>
        <!--template bindings={}-->
    </g> …
Run Code Online (Sandbox Code Playgroud)

svg angular

41
推荐指数
5
解决办法
2万
查看次数