反应使用HTML5视频标签controlsList属性

时间:2017-06-18 08:32:46

标签: reactjs html5-video

尝试使用React组件返回此元素:public class RecipeListViewTest { private RecipeListView fragment; @Mock RecipeListPresenterContract presenter; @Mock RecipeItemListener recipeItemListener; @Mock List<Recipe> recipe; @Before public void setup() { MockitoAnnotations.initMocks(RecipeListViewTest.this); fragment = RecipeListView.newInstance(); } @Test public void testShouldGetAllRecipes() { fragment.displayRecipeData(recipe); RecipeListView spy = Mockito.spy(fragment); verify(recipeItemListener, times(1)).onRecipeItem(); } } 并且仍然显示下载按钮。

没有办法用React传递这个参数(controlsList)?

也试过<video ... controls controlsList="nodownload" />

错误日志: 标记上的未知道具htmlControlsList=。从元素中删除此prop。有关详细信息,请参阅.... URL

2 个答案:

答案 0 :(得分:5)

在React中修复问题之前,您可以添加属性

componentDidMount() {
  this.video.setAttribute("controlsList","nodownload");
}

render() {
  return (
    <video 
      ref={(v)=>{this.video=v}}
      src="myvideo.mp4" 
      controls 
      autoplay />
  )
}

答案 1 :(得分:3)

支持ControlsList API has been reported a couple of weeks ago和相关的PR已在5天前合并。

它应该可以在即将推出的React版本中使用。