RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-339846

Leks's questions

Martin Hope
Leks
Asked: 2023-09-30 16:32:05 +0000 UTC

按键翻转不起作用

  • 6

document.addEventListener('keydown', e => {
    if (e.code == 'KeyW' && e.code == 'KeyQ') {
        console.log('yes')
    };
})

javascript
  • 1 个回答
  • 29 Views
Martin Hope
Leks
Asked: 2023-08-17 18:13:19 +0000 UTC

为什么文本、中心线和标签不显示

  • 5

let canvas = document.getElementById('tutorial');
let c = canvas.getContext('2d');

let data = [16, 68, 20, 30, 54];
let labels = ["JAN", "FEB", "MAR", "APR", "MAY"];

c.fillStyle = 'grey';
c.fillRect(0, 0, 500, 500);
c.fillStyle = 'blue';

for (let i = 0; i < data.length; i++) {
    let dp = data[i];
    c.fillRect(25 + i * 100, 500 - dp * 5 - 30, 50, dp * 5);
}

c.fillStyle = 'black';
c.lineWidth = 2.0;
c.moveTo(30, 10);
c.lineTo(30, 460);
c.lineTo(490, 460);
c.stroke();

c.fillStyle = 'black';
for (let i = 0; i < 6; i++) {
    c.fillText((5 - i) * 20 + '', 4, i * 80 + 60);
    c.beginPath();
    c.moveTo(25, i * 80 + 60);
    c.lineTo(30, i * 80 + 60);
    c.stroke();
}

for (let i = 0; i < 5; i++) {
    c.fillText(labels[i], i * 100 + 50, 475);
}

c.fillStyle = 'white';
c.fillRect(0, 0, 500, 500);

c.fillStyle = 'blue';
for (let i = 0; i < data.length; i++) {
    let dp = data[i];
    c.fillRect(40 + i * 100, 460 - dp * 5, 50, dp * 5);
}
<canvas id="tutorial" width="500" height="500"></canvas>

javascript
  • 1 个回答
  • 21 Views
Martin Hope
Leks
Asked: 2022-08-28 21:51:35 +0000 UTC

文字不出现

  • 0

function toggleText() {
  let button = document.querySelector('.toggle-text-button');
  let text = document.querySelector('#text');
  button.addEventListener('click', () => {
   
    if(text.hasAttributes('hidden') == true){
       console.log('adad')
      text.hidden = '';
    }
    text.hidden = true;
  })
}

toggleText()
<button class="toggle-text-button">Нажмите, чтобы спрятать/показать текст</button>
  <div id="text">Текст</div>

  1. 如果条件被触发,为什么文本不出现?
javascript
  • 3 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2022-08-24 03:04:49 +0000 UTC

表未迭代

  • 0

let arr = Array.from(document.querySelector('#grid').rows)
document.querySelector('#grid').addEventListener('click', event =>{
   if(event.target.dataset.type == 'number'){
      arr.forEach( item => {
         if(item.rowIndex > 0){
           
            arr.sort(() => {
               item.cells[0].firstChild.data > item.cells[0].firstChild.data
            })
            
         }
      }) 
   }
})
table {
    border-collapse: collapse;
  }
  th, td {
    border: 1px solid black;
    padding: 4px;
  }
  th {
    cursor: pointer;
  }
  th:hover {
    background: yellow;
  }
  <table id="grid">
    <thead>
      <tr>
        <th data-type="number">Возраст</th>
        <th data-type="string">Имя</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>5</td>
        <td>Вася</td>
      </tr>
      <tr>
        <td>2</td>
        <td>Петя</td>
      </tr>
      <tr>
        <td>12</td>
        <td>Женя</td>
      </tr>
      <tr>
        <td>9</td>
        <td>Маша</td>
      </tr>
      <tr>
        <td>1</td>
        <td>Илья</td>
      </tr>
    </tbody>
  </table>

  1. 如何使其按年龄从小到大,按名称从 A 到 Z 格式化?
javascript
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-08-21 02:28:54 +0000 UTC

在构造函数中创建方法?

  • 1
  1. 如何在构造方法中创建函数(方法)?

class User {

  constructor(name) {
    this.name = name;
  sayHi() {
    alert('hello');
  }
  }

  

}

// Использование:
let user = new User("Иван");
user.sayHi();

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-08-14 16:45:35 +0000 UTC

为什么圆的 stroke-dashoffset 动画不起作用?

  • 3

<svg id="svg1" xmlns="http://www.w3.org/2000/svg" 
    xmlns:xlink="http://www.w3.org/1999/xlink"   
     width="200" height="200" viewBox="0 0 120 120" >  
      Фон серого цвета
 <rect width='100%' height='100%' fill='grey'/>
 <circle r='50' cx='60' cy='60' fill='none' stroke='white' stroke-width='8' transform='rotate(-90 60 60)' />
 <circle r='50' cx='60' cy='60' fill='none' transform='rotate(-90 60 60)'  stroke-dashoffset='314' stroke-dasharray='314' stroke='dodgerblue' stroke-width='8'>
  <animate 
  attributeName='stroke-dashoffset'
  dur='4s'
  begin='svg1.click'
  values='0,314;314,0'
  fill='freeze'
  />
 </circle>
<text x="50%" y="50%" text-anchor='middle' font-size='20' fill="">click</text> 
</svg> 

svg
  • 2 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-08-06 04:33:35 +0000 UTC

如何立即指定 SVG 元素的旋转中心坐标?

  • 2
  1. 将圆的坐标放在中心只能通过选择来获得 transform='rotate(-90 60 60)'
  2. 如何在不选择的情况下立即将圆的坐标放在中心?

<svg id="svg1" xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  width="200" height="200" viewBox="0 0 120 120" >
  <!-- Фон серого цвета -->
  <rect x='0' y='0' width='100%' height='100%' fill='grey'/>
  <circle r='50' cx='60' cy='60' fill='none' stroke='white' stroke-width='8' transform='rotate(-90 60 60)' />
  <circle r='50' cx='60' cy='60' fill='none' transform='rotate(-90 60 60)' stroke-dashoffset='314' stroke-dasharray='314' stroke='dodgerblue' stroke-width='8'>
  <animate
  attributeName='stroke-dashoffset'
  dur='4s'
  begin='svg1.click'
  values='314; 0'
  />
  </circle>
  <text x="50%" y="50%" text-anchor='middle' font-size='20' fill="">click</text>
</svg>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-08-03 02:28:10 +0000 UTC

圆形动画不适用于stroke-dashoffset?

  • 3

为什么遮罩动画不能与 stroke-dashoffset 一起使用?

<svg id='h' version="1.1" xmlns="http://www.w3.org/2000/svg">
<mask id='mask'>
<circle r="30" cx="50" cy="50" stroke='black' fill="black" stroke-width='50' stroke-dashoffset='20 20'>
<animate
attributeName='stroke-dashoffset'
begin='h.click'
dur='10s'
repeatCount='indefinite'
values='50'
/>
</circle>
<rect width="100%" height="100%" fill="green" />
</mask>
<circle r="30" cx="50" cy="50" fill="orange" />

<rect width="100" height="100" fill='tomato' mask='url(#mask)' />
</svg>

html
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-07-30 08:19:39 +0000 UTC

为什么控制台出现错误?

  • 0

function sum(a){
  let sum = a;
  function count(b){
     return sum += b;
  }
  
   count.toString = function(){
    return sum;
  };
  return count;
};

console.log( sum(1)(2) );
console.log( sum(1)(2)(2) );
console.log( sum(1)(2)(2) );

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-07-23 08:01:34 +0000 UTC

如何将椭圆的颜色更改为黄色?

  • 3

为什么动画命令不起作用<animateColor>?

<svg id="svg1" viewBox="0 0 520 520" width="500" style='border: 1px solid black'>
<ellipse cx="100" cy="50"  rx="80" ry="40" fill="red">
<animateColor attributeName="fill" 
         from="red" to="yellow" dur="3s"
         repeatCount="indefinite"/>
</ellipse>
</svg>

svg
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-07-22 06:53:07 +0000 UTC

使按钮没有背景

  • 2

.gl {
  width: 300px;
  height: 300px;
  display: inline-block;
  max-width: 300px;
  max-height: 200px;
  background-color: #fff;
  position: relative;
  background-image: url('https://i.ibb.co/QfLmLrT/image.jpg');
  background-repeat: no-repeat;
  background-size: contain;
}

.gl:before {
  content: '';
  position: absolute;
  background-color: rgba(0, 0, 0, .5);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

a {
  color: red;
  font-size: 30px;
  cursor: pointer;
}
<div class="gl">
  <button>Know More</button>
</div>

css
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-07-22 06:01:15 +0000 UTC

使用 SVG 或 CSS 为平滑的颜色变化设置动画

  • 4

<svg viewBox="0 0 520 520" width="500" style='border: 1px solid black'>
 
<defs>
<linearGradient id="MyGradient">
      <stop offset="0" style="stop-color:red;"/>
     <stop offset="100%" style="stop-color:blue;">
      <animate attributeName="offset" 
         from="0%" to="100%" dur="5s"
               repeatCount="indefinite"/>
      </stop>

</linearGradient>

  </defs>
<circle cx="75" cy="75" r="70" fill="url(#MyGradient)"/>
</svg>

css
  • 2 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-07-17 06:19:56 +0000 UTC

使对象可迭代的最短方法?

  • 1
  1. 我在这里找到的方式https://learn.javascript.ru/

let range = {
  from: 1,
  to: 5,
};

range[Symbol.iterator] = function(){
  return {
    d: this.from,
    s: this.to,

    next() {
      if( this.d <= this.s ){
        return {done: false, value: this.d++}
      } else{
        return {done: true};
      }
    }
  }
}

let arr = Array.from(range);

console.log( arr );

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-06-24 10:07:48 +0000 UTC

为什么内部带有渐变的蒙版不能应用于图像?

  • 3

<svg width='400' height='400' style='border: 1px solid black'>
  
<radialGradient id='a'>
  <stop offset='40%' stop-color='red'></stop>
  <stop offset='60%' stop-color='blue'></stop>
</radialGradient>

<mask id='b'>
  <circle r="50" cx="50%" cy="50%" fill="url(#a)" />
</mask>
<image x="50%" y="50%" width="291" height="195"
       mask="url(#b)" xlink:href="https://i.ibb.co/1XcpWKV/0E5BJ.png"/>

</svg>

svg
  • 2 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-06-22 10:14:04 +0000 UTC

为什么 clipPath 不适用于图像?

  • 3

<svg width='400' height='400' style='border: 1px solid black'>
<defs>
   <clipPath  id='a'>
      <circle r="30" cy="100" r="90" />
  </clipPath >
</defs>  
  <image x="15%" y="35" width="250" height="250"
      clip-path="url(#a)" xlink:href="https://ibb.co/T0yn3RX"/>
</svg>

svg
  • 2 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-06-18 08:49:01 +0000 UTC

为什么 skew patternTransform 属性不起作用?

  • 2

<svg viewBox="0 0 1000 400" width='1000' height='400' style='border:1px solid black'>
  
  <defs>
    <linearGradient id='b'>
      <stop offset='20%' stop-color='green'></stop>
      <stop offset='40%' stop-color='blue'></stop>
      <stop offset='60%' stop-color='red'></stop>
      <stop offset='80%' stop-color='yellow'></stop>
      <stop offset='100%' stop-color='tomato'></stop>
    </linearGradient>
  </defs>

        <defs>
          <pattern patternTransform='skew(10)' id="a" x='5' y='5' width="40" height="40" patternUnits="userSpaceOnUse">
            <circle r="15" cx="15" cy="15" fill="url(#b)" stroke="" stroke-width=""/>
          </pattern>
        </defs>

  <rect x="0" y="0" width="200" height="200" fill="url(#a)" stroke="black" stroke-width="2"/>
</svg>

svg
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-06-15 05:07:34 +0000 UTC

由于图案中没有足够的空间放置图形

  • 3

<svg viewBox="0 0 1000 400" width='1000' height='400' style='border:1px solid black'>
  
  <defs>
    <linearGradient id='b'>
      <stop offset='20%' stop-color='green'></stop>
      <stop offset='40%' stop-color='blue'></stop>
      <stop offset='60%' stop-color='red'></stop>
      <stop offset='80%' stop-color='yellow'></stop>
      <stop offset='100%' stop-color='tomato'></stop>
    </linearGradient>
  </defs>

        <defs>
          <pattern id="a" x='10' y='10' width="40" height="40" patternUnits="userSpaceOnUse">
            <circle r="15" cx="10" cy="10" fill="url(#b)" stroke="" stroke-width=""/>
          </pattern>
        </defs>

  <rect x="0" y="0" width="200" height="200" fill="url(#a)" stroke="black" stroke-width="2"/>
</svg>

svg
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-05-30 05:41:13 +0000 UTC

为什么没有画线?

  • 0

<svg width='1700' height='500' style='border:1px solid black' viewBox='0 0 400 400'>
  <path d="M15,15 L185,15 Z"/>
</svg>

svg
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-05-26 04:46:53 +0000 UTC

MutationObserver 如何撤消文本中的更改

  • 0

let b = new MutationObserver(a => {
  console.log(a); // console.log(изменения)
});

// наблюдать за всем, кроме атрибутов
b.observe(elem, {
  childList: true, // наблюдать за непосредственными детьми
  subtree: true, // и более глубокими потомками
  characterDataOldValue: true  // передавать старое значение в колбэк
});
<div contentEditable id="elem">Отредактируй <b>меня</b>, пожалуйста</div>

如何使用观察者不改变我这个词?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Leks
Asked: 2020-05-25 05:46:24 +0000 UTC

为什么代码会在观察者中抛出错误

  • 1

示例代码来自哪里

let observer = new MutationObserver(mutationRecords => {
  console.log(mutationRecords);
});

mutationRecords = [{
  type: "childList",
  target: <div#elem>,
  removedNodes: [<b>],
  nextSibling: <text node>,
  previousSibling: <text node>
  // другие свойства пусты
}, {
  type: "characterData"
  target: <text node>
  // ...детали изменений зависят от того, как браузер обрабатывает такое удаление
  // он может соединить два соседних текстовых узла "Отредактируй " и ", пожалуйста" в один узел
  // или может оставить их разными текстовыми узлами
}];
<div contentEditable id="elem">Отредактируй <b>меня</b>, пожалуйста</div>
为什么 console.log 会抛出错误?

javascript
  • 2 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5