小编son*_*ouf的帖子

不允许预设文件导出对象

我有一个carousel文件,我想在其中获取index.js和构建block.build.js,所以我webpack.config.js的:

var config = {
  entry: './index.js',
  output: {
    path: __dirname,
    filename: 'block.build.js',
  },
  devServer: {
    contentBase: './Carousel'
  },
  module : {
    rules : [
      {
        test: /.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
        query: {
          presets: ['react', 'es2015'],
          plugins: ['transform-class-properties']
        }
      }
    ]
  }
};
module.exports = config;
Run Code Online (Sandbox Code Playgroud)

package.json下面,我用的是:

{
  "name": "carousel",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "dependencies": {
    "@babel/core": "^7.0.0-beta.40",
    "babel-cli": "^6.26.0",
    "babel-loader": "^8.0.0-beta.0",
    "babel-plugin-lodash": "^3.3.2",
    "babel-plugin-react-transform": "^3.0.0",
    "babel-preset-react": "^6.24.1",
    "cross-env": …
Run Code Online (Sandbox Code Playgroud)

reactjs webpack babeljs

55
推荐指数
6
解决办法
5万
查看次数

bootstrap 4行高

我尝试用bootstrap 4来做这样的事情在此输入图像描述

在绿色行和红色行的高度相同的大小

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" rel="stylesheet"/>
   <div class="container">
        <div class="row">
          <div class="col-md-8 col-lg-6 B"><div class="card card-inverse" style="background-color: #333; border-color: #333;">
    <img src="http://lorempicsum.com/rio/800/500/4" class="img-fluid" alt="Responsive image">
    
    </div></div>
      <div class="col-md-4 col-lg-3 G">
          <div class="row">
          <div class="col-md-6 col-lg-6 B"><div class="card card-inverse" style="background-color: #333; border-color: #333;">
    <img src="http://lorempicsum.com/rio/800/500/4" class="img-fluid" alt="Responsive image">
    
    </div></div>
       <div class="col-md-6 col-lg-6 B"><div class="card card-inverse" style="background-color: #333; border-color: #333;">
    <img src="http://lorempicsum.com/rio/800/500/4" class="img-fluid" alt="Responsive image">
    
    </div></div>
       <div class="col-md-12"><div class="card card-inverse" style="background-color: #333; border-color: #333;">
    <img src="http://lorempicsum.com/rio/800/500/3" class="img-fluid" alt="Responsive image">
    
    </div></div>
       </div>
    </div> …
Run Code Online (Sandbox Code Playgroud)

css twitter-bootstrap

17
推荐指数
1
解决办法
8万
查看次数

单击下划线动画

我正在尝试在描述中重新创建动画并在此处查看.当链接未被点击时,下划线从右到左动画,下划线在它消失之前从左到右动画.

a {
  color:#00f;
  text-decoration:none;
  display:inline-block;
}
a:after {
  width: 0;
  display:block;
  background:#00f;
  height:3px;
  transition: all .5s ease-in-out;
  content:"";
}
a:hover {
  color:#00f;
}
a:hover:after {
  width:100%;
}
Run Code Online (Sandbox Code Playgroud)
<a href="#">Click first</a>
<a href="#">Click second</a>
Run Code Online (Sandbox Code Playgroud)

javascript css jquery

13
推荐指数
2
解决办法
1478
查看次数

即使使用 flex-shrink,Flex 项目也会收缩:0

flex-shrink属性指定该项目将如何相对于同一容器内的其余灵活项目收缩,因此当我给出其中一个时,flex-shrink0不应该收缩,但它会收缩。

#content {
  -ms-box-orient: horizontal;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -moz-flex;
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: space-around;
  justify-content: space-around;
  -webkit-flex-flow: row wrap;
  flex-flow: row wrap;
  -webkit-align-items: stretch;
  align-items: stretch;
}
.box {
  flex-grow: 1;
  flex-shrink: 0;
  border: 3px solid rgba(0, 0, 0, .2);
}
.box1 {
  flex-grow: 1;
  flex-shrink: 0;
  border: 3px solid rgba(0, 0, 0, .2);
}
Run Code Online (Sandbox Code Playgroud)
<h4>it shinks with a flex-shrink of 0</h4>
<div id="content">
  <div class="box" style="background-color:red;">A</div>
  <div class="box" …
Run Code Online (Sandbox Code Playgroud)

html css flexbox

7
推荐指数
1
解决办法
9128
查看次数

在悬停时进出动画

我试图像这里的效果一样制作一个删除线动画:

删除线的删除线效果

罢工线出现由左到右和消失,从左至右.

@keyframes strike {
  0% {
    width: 0;
  }
  50% {
    width: 100%;
  }
  100% {
    width: 0;
  }
}

.strike {
  position: relative;
}

.strike:hover:after {
  content: ' ';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background: black;
  animation-name: strike;
  animation-duration: 1s;
  animation-timing-function: linear;
  animation-iteration-count: 1;
  animation-fill-mode: fill;
  animation-direction: normal;
}
Run Code Online (Sandbox Code Playgroud)
<div>
  The text in the span <span class="strike">is what I want to strike out</span>.
</div>
Run Code Online (Sandbox Code Playgroud)

有没有办法只用CSS实现?

css css3 css-animations

7
推荐指数
1
解决办法
1051
查看次数

在javascript中的乒乓游戏碰撞

嗨,我尝试做一个乒乓球比赛.但我的碰撞方法不起作用我看不出我做错了什么.球传过球员.碰撞方法对我来说似乎很好

 if (player.left < ball.right && player.right > ball.left &&
            player.top < ball.bottom && player.bottom > ball.top) {
            ball.vel.x = -ball.vel.x;
        }
Run Code Online (Sandbox Code Playgroud)

class Vec {
  constructor(x = 0, y = 0) {
    this.x = x;
    this.y = y;
  }
}

class Rect {
  constructor(w, h) {
    this.pos = new Vec;
    this.size = new Vec(w, h)
  }
  get left() {
    return this.pos.x - this.size.x / 2;
  }
  get right() {
    return this.pos.x - this.size.x / 2;
  }
  get top() {
    return …
Run Code Online (Sandbox Code Playgroud)

javascript

7
推荐指数
1
解决办法
127
查看次数

WooCommerce获取类别slug - 带有函数的未定义属性通知

我使用此函数将woocommerce类别id转换为类别slug

function woocommerceCategorySlug($id){
    $term = get_term( $id, 'product_cat' );
    return $term->slug;       
}
Run Code Online (Sandbox Code Playgroud)

这是有效的,但问题是我收到了通知

Notice: Undefined property: WP_Error::$slug 
Run Code Online (Sandbox Code Playgroud)

有没有办法避免这个通知?

php wordpress product categories woocommerce

3
推荐指数
1
解决办法
6071
查看次数

编辑路径点或线的选择

我正在尝试找到一种方法,通过在 html5 画布上通过鼠标单击选择路径点来拖放带有 javascript 的多边形点或线

有点像下图 在此处输入图片说明

通过单击并将选定的点拖动到新位置来移动选定的点

var canvas=document.getElementById("canvas");
var context=canvas.getContext("2d");
var cw=canvas.width;
var ch=canvas.height;
function reOffset(){
  var BB=canvas.getBoundingClientRect();
  offsetX=BB.left;
  offsetY=BB.top;        
}
var offsetX,offsetY;
reOffset();
window.onscroll=function(e){ reOffset(); }

context.lineWidth=2;
context.strokeStyle='blue';

var coordinates = [];
var isDone=false;

$('#done').click(function(){
  isDone=true;
});

$("#canvas").mousedown(function(e){handleMouseDown(e);});

function handleMouseDown(e){
  if(isDone || coordinates.length>10){return;}

  // tell the browser we're handling this event
  e.preventDefault();
  e.stopPropagation();

  mouseX=parseInt(e.clientX-offsetX);
  mouseY=parseInt(e.clientY-offsetY);
  coordinates.push({x:mouseX,y:mouseY});
  drawPolygon();
}

function drawPolygon(){
  context.clearRect(0,0,cw,ch);
  context.beginPath();
  context.moveTo(coordinates[0].x, coordinates[0].y);
  for(index=1; index<coordinates.length;index++) {
    context.lineTo(coordinates[index].x, coordinates[index].y);
  }
  context.closePath();
  context.stroke();
}
Run Code Online (Sandbox Code Playgroud)
body{ background-color: ivory; }
#canvas{border:1px …
Run Code Online (Sandbox Code Playgroud)

javascript html5-canvas

3
推荐指数
1
解决办法
860
查看次数