我无法在Mac OS X上的JavaFX应用程序中显示表情符号.在Linux上,只要系统上有表情符号字符(Symbo,Noto Emoji),字体替换就会启动.
然而,在OS X上,没有这样的运气.我尝试添加Symbola字体作为资源,只有在我将标签的字体更改为Symbola时才有效.我不想这样做是因为:
Apple有"Apple Color Emoji"字体.如果我将标签设置为该字体,则会显示表情符号,但文本间距不稳定.
以下是查看问题的示例应用程序:
import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
Group root = new Group();
Scene scene = new Scene(root, 300, 130, Color.WHITE);
GridPane gridpane = new GridPane();
gridpane.setPadding(new Insets(5));
// Add cat emoji
Label label = new …Run Code Online (Sandbox Code Playgroud) 我有一个使用 v3 的组合 API 的 Vue 组件:
<template>
<input type="checkbox" v-model="playing" id="playing" @input="$emit('play', $event.target.value)" />
<label for="playing" >{{ playing ? 'Pause' : 'Play' }}</label>
</template>
<script>
export default {
props: {
done: Boolean
},
setup(props) {
const playing = ref(true)
watchEvent(() => {
if (props.done) {
playing.value = false
this.$emit('play', playing.value)
}
}
return { playing }
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
当 watchEvent 运行时,我收到错误 Cannot read property "$emit" of undefined。看起来我没有使用错误类型的函数(箭头与普通函数)。
无论是函数还是箭头函数,似乎this始终未定义setup()。