我有:
<a href={link} on:click={() => func(param)} on:auxclick={() => func(param)}>
click
</a>
Run Code Online (Sandbox Code Playgroud)
有什么方法可以将on:click和组合on:auxclick成on:click|auxclick,或者类似这种效果的东西吗?(下面的代码给了我一个语法错误。)
<a href={link} on:click|auxclick={() => func(param)}>
click
</a>
Run Code Online (Sandbox Code Playgroud)
编辑:为了更清楚的描述
我编写了一个程序,从文本文件的每一行读取四个变量(三个字符串和一个字符).但是当我显示变量时,每行末尾会弹出一个意外的字符.(我确保变量的长度足够大).
为什么是这样?(再次溢出缓冲区?)我该如何解决这个问题?
文本文件内容:
M0001 Cool Name F 123-456789 M0002 Name Cool M 987-654321
码:
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *text;
char id[6], name[101], gender, contact[13];
text = fopen("test.txt", "r");
while (fscanf(text, "%s %[^\n]s %c %s\n", id, name, &gender, contact) != EOF)
printf("%s %s %c %s\n", id, name, gender, contact);
fclose(text);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我期望的输出:
M0001 Cool Name F 123-456789 M0002 Name Cool M 987-654321
我得到的是:
M0001 Cool Name F 123-456789 1?4 M0002 Name Cool M 987-654321 1?4
我正在尝试将对象作为参数传递给构造函数.是否允许以下代码?特别是我进入Toyota和Corolla进入的部分Car car,然后进入String brand和String model.
public class Car {
private String brand, model;
public Car(String brand, String model) {
this.brand = brand;
this.model = model;
}
// getters and setters
}
public class Customer {
private String name;
private Car car;
public Customer(String name, Car car) {
this.name = name;
this.car = car;
}
// getters and setters
}
public class Service {
Customer customer = new Customer("John", "Toyota", "Corolla");
}
Run Code Online (Sandbox Code Playgroud)