问题:我想test
在单击<path>
SVG图形中的元素时运行该函数.现在,当我点击元素时没有任何反应.无论其-当我更换ng-click
与onclick="alert('success')"
警报工作正常.有什么建议?
在我的代码中......
我的HTML部分......
<div ng-controller="converter">
<embed src="/image.svg">
<!--This button successfully runs the test function-->
<button ng-click="test()">Test</button>
</div>
Run Code Online (Sandbox Code Playgroud)
我的app.js ......
var app = angular.module('app', []);
app.controller('converter', ['$scope', '$http', function($scope, $http){
$scope.test = function(){
console.log("this click event is working");
}
}]);
Run Code Online (Sandbox Code Playgroud)
我的嵌入式SVG文件的一部分......
<rect id="e1-1-2" data-name="e1-1" class="cls-35" x="14" y="106" width="57" height="22" ng-click="test()"/>
Run Code Online (Sandbox Code Playgroud)
(这是完整的代码,对于那些感兴趣的人:https://github.com/cwklausing/angular_guitar)
我想知道React片段是否与Enzyme的快照兼容.现在看来React 16+的片段在酶的shallow()
方法中被渲染为符号,这会导致转换错误:"TypeError: Cannot convert a Symbol value to a string"
.
这是我的测试:
it('should render successfully', () => {
const wrapper = shallow(
<Sections
data={mappedMockData}
sections={mappedMockData.sections}
eligibility={mockEligibility}
/>
);
console.log(wrapper.debug());
expect(wrapper).toMatchSnapshot();
Run Code Online (Sandbox Code Playgroud)
这是我的console.log的输出:
<Symbol(react.fragment)>
<div className="content-container">
<div className="flex">
<div className="sections-wrap">
<Connect(Section1) />
<Connect(Section2) />
</div>
<Connect(Section3) />
</div>
</div>
<div className="content-container">
<Connect(Section4) />
<Connect(Section5) />
</div>
</Symbol(react.fragment)>
Run Code Online (Sandbox Code Playgroud)
值得注意的是:我已经更新了我的酶和React,并且已经使用了一个适配器,正如酶的迁移指南所示.我无法在堆栈溢出或Github上找到其他类似的问题.提前感谢任何见解!
我想在获取事件侦听器内访问我的服务工作人员的范围。我计划的解决方法是使用window.location.host
, 但window
在服务工作人员内部不可用。我还尝试使用 ServiceWorkerRegistration.scope (MDN doc),它将返回我想要的值,但这在 fetch 事件处理程序中也无法访问。
我希望有类似的东西event.scope
(在注册处理程序中可用),但用于获取处理程序。这可能吗?
javascript service-worker progressive-web-apps service-worker-events