当前位置: 首页 > news >正文

做饲料推广哪个网站好如何在网络上推广产品

做饲料推广哪个网站好,如何在网络上推广产品,网站建设文本居中代码,建设厅科技中心网站拖拽功能在平时开发中是很常见的,这篇文章主要使用react-beautiful-dnd插件实现此功能。 非常好用,附上GitHub地址:https://github.com/atlassian/react-beautiful-dnd 安装及引入 // 1.引入 # yarn yarn add react-beautiful-dnd# npm npm…

拖拽功能在平时开发中是很常见的,这篇文章主要使用react-beautiful-dnd插件实现此功能。
非常好用,附上GitHub地址:https://github.com/atlassian/react-beautiful-dnd


安装及引入

// 1.引入
# yarn
yarn add react-beautiful-dnd# npm
npm install react-beautiful-dnd --save

具体使用
 

import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";// 样式相关 代码
const grid = 8;
// 垂直样式
// const getItemStyle = (isDragging, draggableStyle) => ({
//     // some basic styles to make the items look a bit nicer
//     userSelect: "none",
//     padding: grid * 2,
//     margin: `0 0 ${grid}px 0`,
//
//     // change background colour if dragging
//     background: isDragging ? "lightgreen" : "grey",
//
//     // styles we need to apply on draggables
//     ...draggableStyle
// });
// const getListStyle = isDraggingOver => ({
//     background: isDraggingOver ? "lightblue" : "lightgrey",
//     padding: grid,
//     width: 250,
// });// 水平样式
const getItemStyle = (isDragging, draggableStyle) => ({// some basic styles to make the items look a bit niceruserSelect: 'none',padding: grid * 2,margin: `0 ${grid}px 0 0`,// change background colour if draggingbackground: isDragging ? 'lightgreen' : 'grey',// styles we need to apply on draggables...draggableStyle,
});
const getListStyle = isDraggingOver => ({background: isDraggingOver ? 'lightblue' : 'lightgrey',display: 'flex',padding: grid,overflow: 'auto',
});class App extends React.Component {constructor(props) {super(props)this.state = {items: [{id: 'item-0', content: 'hello'},{id: 'item-1', content: 'I'},{id: 'item-2', content: 'am'},{id: 'item-3', content: '卡'},{id: 'item-4', content: '特'},{id: 'item-5', content: '洛'},]};}// a little function to help us with reordering the resultreOrder = (list, startIndex, endIndex) => {const result = Array.from(list);const [removed] = result.splice(startIndex, 1);result.splice(endIndex, 0, removed);return result;};onDragEnd = (result) => {// dropped outside the listif (!result.destination) {return;}const items = this.reOrder(this.state.items,result.source.index,result.destination.index);this.setState({items});}render () {return (<div className="App"><DragDropContext onDragEnd={this.onDragEnd}><Droppable droppableId="droppable" direction="horizontal">{(provided, snapshot) => (<divref={provided.innerRef}style={getListStyle(snapshot.isDraggingOver)}{...provided.droppableProps}>{this.state.items.map((item, index) => (<Draggable key={item.id} draggableId={item.id} index={index}>{(provided, snapshot) => (<divref={provided.innerRef}{...provided.draggableProps}{...provided.dragHandleProps}style={getItemStyle(snapshot.isDragging,provided.draggableProps.style)}>{item.content}</div>)}</Draggable>))}{provided.placeholder}</div>)}</Droppable></DragDropContext></div>);}
}export default App;

说明一下:<Droppable />中的 direction 属性可以控制是水平方向还是垂直方向,配合相关 getItemStyle 和 getListStyle 的代码,可做到。
效果展示

补充一下: 如果你是react-creat-app 创建的项目,则需要删除代码里自带的react 严格模式。否则拖拽效果出不来。

http://www.dinnco.com/news/81326.html

相关文章:

  • 网站友情链接怎么添加网站权重查询工具
  • 建设信息门户网站佛山网站定制
  • 个人网站可以做商城吗全网最好的推广平台
  • 仿造整个网站搜索引擎优化网站
  • 建设网站的五个步骤郑州网站推广电话
  • 微商城登录南昌网站seo
  • 有没有适合宝妈找工作做兼职的网站电商平台怎么加入
  • cms做网站可以做些什么网站济南网站设计
  • 企业网站模板 下载 免费自己做网站制作流程
  • 做数据收集网站安徽seo团队
  • 政府网站集约化建设作用seo排名培训
  • 新建网站seo优化怎么做网络营销的优势有哪些
  • 个人备案网站经营手游推广渠道和推广方式
  • 网站上面做测试题百度广告屏蔽
  • 做网站的像素是多少怎么在百度上做广告推广
  • 邢台公司做网站网站怎么做
  • 服务器 网站建设整站优化 快速排名
  • 为中小型企业构建网站东莞网站建设优化排名
  • 网站的宣传推广推广计划方案
  • 在哪个网站上面可以接项目做icp备案查询官网
  • 做商城网站要什么证件深圳seo优化方案
  • 做网站 二维码登录搜索引擎网页
  • 很有设计感的企业网站凤山网站seo
  • 网站推广 英文东莞seo收费
  • 橙子建站是什么软件百度推广收费标准
  • 电商网站建设思维导图百度旗下推广平台有哪些
  • 做网站测试心得网站seo分析工具
  • 帝国cms 做的博客网站互联网创业项目
  • 如何做网站渗透测试百度推广官方
  • 武汉有几个区下载优化大师并安装