Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular ionic ts部件无法正确放置JavaScript_Angular_Ionic Framework_Ionic2 - Fatal编程技术网

Angular ionic ts部件无法正确放置JavaScript

Angular ionic ts部件无法正确放置JavaScript,angular,ionic-framework,ionic2,Angular,Ionic Framework,Ionic2,我正在尝试为我的Ionic mobile应用程序创建这样的应用程序, 我有一个小问题,实际上这个动画部分对我不起作用,有人知道如何为爱奥尼亚正确放置脚本部分, 请帮我解决这个问题 谢谢 这是我的代码示例 这是我的密码 html 我想知道如何为爱奥尼亚正确放置此部件 const clap = document.getElementById('clap') const clapIcon = document.getElementById('clap--icon') const clapCount =

我正在尝试为我的Ionic mobile应用程序创建这样的应用程序, 我有一个小问题,实际上这个动画部分对我不起作用,有人知道如何为爱奥尼亚正确放置脚本部分, 请帮我解决这个问题 谢谢

这是我的代码示例

这是我的密码

html

我想知道如何为爱奥尼亚正确放置此部件

const clap = document.getElementById('clap')
const clapIcon = document.getElementById('clap--icon')
const clapCount = document.getElementById('clap--count')
const clapTotalCount = document.getElementById('clap--count-total')
const initialNumberOfClaps = generateRandomNumber(500, 10000);
const btnDimension = 80
const tlDuration = 300
let numberOfClaps = 0
let clapHold;

const triangleBurst = new mojs.Burst({
  parent: clap,
  radius: {50:95},
  count: 5,
  angle: 30,
  children: {
    shape: 'polygon',
    radius: {6: 0},
    scale: 1,
    stroke: 'rgba(211,84,0 ,0.5)',
    strokeWidth: 2,
    angle: 210,
    delay: 30,
    speed: 0.2,
    easing: mojs.easing.bezier(0.1, 1, 0.3 ,1),
    duration: tlDuration
  } 
})
const circleBurst = new mojs.Burst({
  parent: clap,
  radius: {50:75},
  angle: 25,
  duration: tlDuration,
  children: {
    shape: 'circle',
    fill: 'rgba(149,165,166 ,0.5)',
    delay: 30,
    speed: 0.2,
    radius: {3: 0},
    easing: mojs.easing.bezier(0.1, 1, 0.3, 1),
  }
})
const countAnimation = new mojs.Html({
  el: '#clap--count',
  isShowStart: false,
  isShowEnd: true,
  y: {0: -30},
  opacity: {0:1},
  duration: tlDuration
}).then({
  opacity: {1:0},
  y: -80,
  delay: tlDuration/2
})
const countTotalAnimation = new mojs.Html({
  el: '#clap--count-total',
  isShowStart: false,
  isShowEnd: true,
  opacity: {0:1},
  delay: 3*(tlDuration)/2,
  duration: tlDuration,
  y: {0: -3}
})
const scaleButton = new mojs.Html({
  el: '#clap',
  duration: tlDuration,
  scale: {1.3: 1},
  easing: mojs.easing.out
})
clap.style.transform = "scale(1, 1)" /*Bug1 fix*/

const animationTimeline = new mojs.Timeline()
animationTimeline.add([
  triangleBurst,
  circleBurst,
  countAnimation,
  countTotalAnimation,
  scaleButton
])


clap.addEventListener('click', function() {
   repeatClapping();
})

clap.addEventListener('mousedown', function() {
   clapHold = setInterval(function() {
   repeatClapping();
   }, 400)
})

clap.addEventListener('mouseup', function() {
 clearInterval(clapHold);
})


function repeatClapping() {
 updateNumberOfClaps()
 animationTimeline.replay()
 clapIcon.classList.add('checked')
}

function updateNumberOfClaps() {
  numberOfClaps < 50 ? numberOfClaps++ : null
  clapCount.innerHTML = "+" + numberOfClaps
  clapTotalCount.innerHTML = initialNumberOfClaps + numberOfClaps
}

function generateRandomNumber(min, max) {
  return Math.floor(Math.random()*(max-min+1)+min);
}

我会创建像clap这样的专用组件

但首先,您需要将moj添加到页面中

<script src="https://cdnjs.cloudflare.com/ajax/libs/mo-js/0.288.1/mo.min.js"></scrip>
注意:如果需要,您可以创建类似的打字

现在是创建自定义组件的时候了

我们将使用ViewChild而不是document.getElementById来保存对DOM元素的引用。为此,我们需要在元素49上放置模板引用{ 警报“限制50拍”; 回来 } 这个.currentClaps++; 这个.claps++; this.clapsChange.emitthis.claps; this.animationTimeline.replay; this.clapIconChecked=true; } onClapMouseDown{ this.clapHold=setInterval=>{ 这是重复的鼓掌; }, 400; } 盘状滑鼠{ clearIntervalthis.clapHold; } } 正如你所看到的,这里没有魔法。这是一个具有双向绑定的简单组件,我们可以在任何地方使用,如下所示:

home.html

home.ts

导出类主页{ claps=发电机地址编号500,10000; } 函数生成器DOMNumbermin,最大值{ 返回Math.floorMath.random*max-min+1+min; }
试试看

我会创建像clap这样的专用组件

但首先,您需要将moj添加到页面中

<script src="https://cdnjs.cloudflare.com/ajax/libs/mo-js/0.288.1/mo.min.js"></scrip>
注意:如果需要,您可以创建类似的打字

现在是创建自定义组件的时候了

我们将使用ViewChild而不是document.getElementById来保存对DOM元素的引用。为此,我们需要在元素49上放置模板引用{ 警报“限制50拍”; 回来 } 这个.currentClaps++; 这个.claps++; this.clapsChange.emitthis.claps; this.animationTimeline.replay; this.clapIconChecked=true; } onClapMouseDown{ this.clapHold=setInterval=>{ 这是重复的鼓掌; }, 400; } 盘状滑鼠{ clearIntervalthis.clapHold; } } 正如你所看到的,这里没有魔法。这是一个具有双向绑定的简单组件,我们可以在任何地方使用,如下所示:

home.html

home.ts

导出类主页{ claps=发电机地址编号500,10000; } 函数生成器DOMNumbermin,最大值{ 返回Math.floorMath.random*max-min+1+min; }
试一试

最初,我会从实现功能开始,比如当用户单击时,鼓掌次数会增加。simple@OmurbekKadyrbekov先生,您的解决方案真的很好,但是当像这样的动画部分使用mojs库时,您需要导入它,请参阅。然后,您将用angular样式重写js文件。最初,我将从实现功能开始,比如当用户单击时鼓掌次数增加。simple@OmurbekKadyrbekov先生,您的解决方案真的很好,但是当像这样的动画部分使用mojs库时,您需要导入它,请参阅。然后你将用angular Style重写js文件先生,我面临一些错误,Typescript错误找不到名称“GeneratorAndomNumber”。claps=发电机地址编号500,10000;我将GeneratorDomainNumber移动到home.ts我添加了该部分,但显示错误类型脚本错误找不到名称“GeneratorDomainNumber”。claps=发电机地址编号500,10000;这是我添加的代码部件导出类支持页面{claps=generateRandomNumber500,10000;constructor公共navCtrl:NavController,public navParams:navParams,public viewCtrl:ViewController{function generateRandomNumbermin,max{return Math.floorMath.random*max-min+1+min;}函数应该在类之外。或者您可以使用类似Sir的方法,我面临一些错误,Typescript错误找不到名称“generateRandomNumber”。claps=generateRandomNumber500,10000;我将generateRandomNumber移动到home。ts我添加了该部分,但显示错误Typescript错误找不到名称“generateRandomNumber”。claps=generateRandomNumberdomNumber500,10000;这是我添加的代码部分导出类支持页{claps=generateRandomNumber500,10000;构造函数public navCtrl:NavController,public navParams:navParams,public viewCtrl:ViewController{function generateRandomNumbermin,max{return Math.floorMath.random*max-min+1+min;}函数应该在类之外。或者您可以使用如下方法
<script src="https://cdnjs.cloudflare.com/ajax/libs/mo-js/0.288.1/mo.min.js"></scrip>