此处将为大家介绍关于【BUG】VUErouter切换created不执行的问题的详细内容,并且为您解答有关vuerouter切换效果的相关问题,此外,我们还将为您介绍关于./node_modules/
此处将为大家介绍关于【BUG】VUE router 切换 created 不执行的问题的详细内容,并且为您解答有关vuerouter切换效果的相关问题,此外,我们还将为您介绍关于./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”、centos7 开机/etc/rc.local 不执行的问题、CountDownTimer 使用,以及避免最后一次 tick 不执行的问题、mac 下的 /etc/bash_profile 不执行的问题的有用信息。
本文目录一览:- 【BUG】VUE router 切换 created 不执行的问题(vuerouter切换效果)
- ./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”
- centos7 开机/etc/rc.local 不执行的问题
- CountDownTimer 使用,以及避免最后一次 tick 不执行的问题
- mac 下的 /etc/bash_profile 不执行的问题
【BUG】VUE router 切换 created 不执行的问题(vuerouter切换效果)
问题原因:是 vue 文件里 name 名称与其他 vue 文件里面的 name 重复,和他重名的组件使用了 keepActive 为 true,keep-active 根据组件的 name 去匹配。
解决方法:换名字即可解决,换名字后使用 keepActive,可使用 activated 替换 created 方法。
./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”
如何解决./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”
./node_modules/react-router-dom/react-router-dom.js Attempted import error: ''Navigate'' is not exported from ''react-router''.
react-router-dom的版本是6.0.0-alpha.2,而react-router是5.2.0。 两者均已正确安装。我不确定如何解决此错误。有人可以给我任何可能的解决方法吗?
我的代码中甚至没有<Navigate to=?>
行。
解决方法
为什么只安装两个都需要,这可以工作
- 执行npm删除react-router
- 删除node_modules
- 纱线安装或npm安装和
- 启动纱线或启动npm
centos7 开机/etc/rc.local 不执行的问题
最近发现centos7 的/etc/rc.local不会开机执行,于是认真看了下/etc/rc.local文件内容的就发现了问题的原因了
翻译:
于是我有确认了下/etc/rc.local的权限
/etc/rc.d/rc.local没有执行权限,于是按说明的内容执行
重启后发现/etc/rc.local能够执行了。
看样子是版本的变迁,/etc/rc.local /etc/rc.d/rc.local正在弃用的路上。
CountDownTimer 使用,以及避免最后一次 tick 不执行的问题
谷歌的 CountDownTimer 有个 bug, 倒计时最后一个 tick 不起作用,外国友人也遇到了.
https://stackoverflow.com/questions/8857590/android-countdowntimer-skips-last-ontick
可使用这个自定义的 Timer 避免 bug, 转载
https://www.codeproject.com/Articles/1093931/Custom-Countdown-Timer-in-Java-Android
package com.ad.paltform.util;
import android.os.Handler;
import android.os.Looper;
import com.ad.paltform.log.LogAD;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class CustomCountDownTimer {
public static final String TAG = "CustomCountDownTimer";
//thread on which the callbacks will be called
private Handler mainThreadHandler = new Handler(Looper.getMainLooper());
//listener interface which is to be implemented by the users of the count down timer
public interface TimerTickListener {
/**
* Callback on each tick
*
* @param millisLeft time left in millisec for the timer to shutdown
*/
public void onTick(long millisLeft);
/**
* Callback to be invokded when timer''s time finishes
*/
public void onFinish();
/**
* Callback to be invokded when timer is canceled
*/
public void onCancel();
}
/**
* Inner class which delegates the events to callbacks provided in the TimerTickListener
*/
private class TimerRunnable implements Runnable {
public void run() {
if (isCancelled) {
scheduler.shutdown();
LogAD.d(TAG, "timer was canceled");
mainThreadHandler.post(new Runnable() {
@Override
public void run() {
tickListener.onCancel();
}
});
} else if (isPaused) {
LogAD.d(TAG, "isPaused skip this tick");
} else {
stopTimeInFuture = stopTimeInFuture - countdownInterval;
mainThreadHandler.post(new Runnable() {
long millisLeft = stopTimeInFuture;
@Override
public void run() {
if (millisLeft <= 0) {
tickListener.onFinish();
scheduler.shutdown();
} else {
tickListener.onTick(millisLeft);
}
}
});
}
}
}
//Millis since epoch when alarm should stop.
private long millisInFuture;
//The interval in millis that the user receives callbacks
private final long countdownInterval;
//the time at which timer is to stop
private long stopTimeInFuture;
//boolean representing if the timer was cancelled
private boolean isCancelled = false;
//boolean representing if the timer was paused
private boolean isPaused = false;
//listener which listens to the timer events
private TimerTickListener tickListener;
//scheduler which provides the thread to create timer
private ScheduledExecutorService scheduler;
/**
* Constructor
*
* @param millisInFuture time in millisec for which timer is to run
* @param countDownInterval interval frequency in millisec at which the callback will be invoked
* @param tickListener implementation of TimerTickListener which provides callbacks code
*/
public CustomCountDownTimer(long millisInFuture, long countDownInterval,
TimerTickListener tickListener) {
this.millisInFuture = millisInFuture;
stopTimeInFuture = millisInFuture;
countdownInterval = countDownInterval;
this.tickListener = tickListener;
scheduler = Executors.newSingleThreadScheduledExecutor();
}
/**
* Start the countdown.
*/
public synchronized void start() {
isCancelled = false;
isPaused = false;
scheduler.scheduleWithFixedDelay(new TimerRunnable(), countdownInterval, countdownInterval,
TimeUnit.MILLISECONDS);
}
/**
* Cancels the countdown timer
*/
public synchronized final void cancel() {
isCancelled = true;
}
public synchronized final void pause() {
isPaused = true;
}
public synchronized final void resume() {
isPaused = false;
}
/**
* Extends the time of the countdown timer
*
* @param delta time in millisec by which timer is to be extended
*/
public void extendTime(long delta) {
stopTimeInFuture = stopTimeInFuture + delta;
millisInFuture = millisInFuture + delta;
}
}
在一个项目中看到了 CountDownTimer, 之前都是用 Handler.post 实现,遇到了整理一下
countDownTimer = new CountDownTimer(8000, 1000) { @Override public void onTick(long millisUntilFinished) { //UI线程调用. } @Override public void onFinish() { jump(); } }; countDownTimer.start();
countDownTimer 可以在任何时候被终止:
countDownTimer.cancel();
参考 http://www.jianshu.com/p/3c10432a4726
mac 下的 /etc/bash_profile 不执行的问题
最近入手一台新 mac, 在设置环境时,发现~/.bashrc 不执行,然后发现 /etc/profile 也不执行,真是大写的尴尬。
原因: zsh 和 bash 有别, zsh 不执行上述脚本,需要改为 bash 后,才执行。
至于 zsh 和 bash 之间的相互切换,网上一搜一大推,故不赘述。
今天的关于【BUG】VUE router 切换 created 不执行的问题和vuerouter切换效果的分享已经结束,谢谢您的关注,如果想了解更多关于./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”、centos7 开机/etc/rc.local 不执行的问题、CountDownTimer 使用,以及避免最后一次 tick 不执行的问题、mac 下的 /etc/bash_profile 不执行的问题的相关知识,请在本站进行查询。
本文标签: