烟若柳尘

文章 评论 浏览 30

烟若柳尘 2025-02-20 23:37:28

如果要将颜色(哪种类型为)绑定到视图,则可以使用绑定值转换器实现这一目标。

我创建了一个演示来实现这一目标,您可以参考以下代码:

mymodel.cs

public class MyModel: INotifyPropertyChanged
{
    string name;
    public string Name
    {
        set
        {
            if (name != value)
            {
                name = value;
                OnPropertyChanged("Name");

            }
        }
        get
        {
            return name;
        }
    }


    string _value;
    public string Value
    {
        set
        {
            if (_value != value)
            {
                _value = value;
                OnPropertyChanged("Value");

            }
        }
        get
        {
            return _value;
        }
    }

    private string _textColor = "Green";
    public string TextColor
    {
        get { return _textColor; }
        set
        {
            _textColor = value;

            OnPropertyChanged("TextColor");

        }
    }


    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged(string propertyName)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

myviewModel.cs

public class MyViewModel
{
    public ObservableCollection<MyModel> dataList { get; set; }

    public ICommand ColorChangeCommand { protected set; get; }
    public MyViewModel()
    {
        dataList = new ObservableCollection<MyModel>();
        dataList.Add(new MyModel() { Name = "test1", Value = "1" });
        dataList.Add(new MyModel() { Name = "test2", Value = "2" });
        dataList.Add(new MyModel() { Name = "test3", Value = "3" });
        ColorChangeCommand = new Command<MyModel>(async (key) =>
        {
            key.TextColor = "Red";

        });

    }
}

strigntocolorConverter.cs

public class StringToColorConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var color = value.ToString();
        switch (color)
        {
            case "Green":
                return Colors.Green;
            case "Red":
                return Colors.Red;
            default:
                return Colors.Yellow;
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return null;
    }
}

a用法:

 <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp0706.Tab1"
             xmlns:local="clr-namespace:MauiApp0706" 
             Title="Tab1">

    <ContentPage.Resources>
        <ResourceDictionary>
            <local:StringToColorConverter x:Key="ColorConverter" />
        </ResourceDictionary>
    </ContentPage.Resources>
    <VerticalStackLayout>
        <CollectionView
             ItemsSource="{Binding dataList}"
             x:Name="mylistview"
             >
            <CollectionView.ItemTemplate>
                <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Grid Column="0">
                            <Label Text="{Binding Name}" TextColor="{Binding TextColor, Converter = {StaticResource ColorConverter}}"/>
                            </Grid>
                            <Grid Column="1">
                            <Label Text="{Binding Value}" TextColor="{Binding TextColor, Converter = {StaticResource ColorConverter}}"/>
                            </Grid>
                            <Grid Column="2">
                                <Button Text="change" Command="{Binding BindingContext.ColorChangeCommand, Source={x:Reference Name=mylistview} }"  CommandParameter="{Binding .}"></Button>
                            </Grid>

                        </Grid>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </VerticalStackLayout>
</ContentPage>

If you want to bind color(which type is string) to your view, you can use Binding value converters to achieve this.

I created a demo to achieve this , you can refer to the following code:

MyModel.cs

public class MyModel: INotifyPropertyChanged
{
    string name;
    public string Name
    {
        set
        {
            if (name != value)
            {
                name = value;
                OnPropertyChanged("Name");

            }
        }
        get
        {
            return name;
        }
    }


    string _value;
    public string Value
    {
        set
        {
            if (_value != value)
            {
                _value = value;
                OnPropertyChanged("Value");

            }
        }
        get
        {
            return _value;
        }
    }

    private string _textColor = "Green";
    public string TextColor
    {
        get { return _textColor; }
        set
        {
            _textColor = value;

            OnPropertyChanged("TextColor");

        }
    }


    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged(string propertyName)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

MyViewModel.cs

public class MyViewModel
{
    public ObservableCollection<MyModel> dataList { get; set; }

    public ICommand ColorChangeCommand { protected set; get; }
    public MyViewModel()
    {
        dataList = new ObservableCollection<MyModel>();
        dataList.Add(new MyModel() { Name = "test1", Value = "1" });
        dataList.Add(new MyModel() { Name = "test2", Value = "2" });
        dataList.Add(new MyModel() { Name = "test3", Value = "3" });
        ColorChangeCommand = new Command<MyModel>(async (key) =>
        {
            key.TextColor = "Red";

        });

    }
}

StringToColorConverter.cs

public class StringToColorConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var color = value.ToString();
        switch (color)
        {
            case "Green":
                return Colors.Green;
            case "Red":
                return Colors.Red;
            default:
                return Colors.Yellow;
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return null;
    }
}

A usage:

 <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp0706.Tab1"
             xmlns:local="clr-namespace:MauiApp0706" 
             Title="Tab1">

    <ContentPage.Resources>
        <ResourceDictionary>
            <local:StringToColorConverter x:Key="ColorConverter" />
        </ResourceDictionary>
    </ContentPage.Resources>
    <VerticalStackLayout>
        <CollectionView
             ItemsSource="{Binding dataList}"
             x:Name="mylistview"
             >
            <CollectionView.ItemTemplate>
                <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Grid Column="0">
                            <Label Text="{Binding Name}" TextColor="{Binding TextColor, Converter = {StaticResource ColorConverter}}"/>
                            </Grid>
                            <Grid Column="1">
                            <Label Text="{Binding Value}" TextColor="{Binding TextColor, Converter = {StaticResource ColorConverter}}"/>
                            </Grid>
                            <Grid Column="2">
                                <Button Text="change" Command="{Binding BindingContext.ColorChangeCommand, Source={x:Reference Name=mylistview} }"  CommandParameter="{Binding .}"></Button>
                            </Grid>

                        </Grid>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </VerticalStackLayout>
</ContentPage>

.NET MAUI:如何在结合中引用颜色?

烟若柳尘 2025-02-20 20:52:39

您可以将稀有物对象更改为此(路径为值):

const rarities = {
  Exclusive: '../../public/Rarity_Exclusive.png',
  Ultra: '../../public/Rarity_Ultra.png',
}

然后,您可以通过稀有性访问对象的图像。

function KnifesComponent() {

  const knifeCollection = collection(db, "knives");
  const [knives, setKnives] = useState([]);
  
  useEffect(() => {
    onSnapshot(knifeCollection, (snapshot) => {
      setKnives(snapshot.docs.map((doc) => ({ ...doc.data(), id: doc.id })));
    });
  }, []);  

  return (
    {
      knives.map((skin) => {
        return (
          {skin.rarity} // Returns "Ultra" for Example
          <div>
            <img src={require(rarities[skin.rarity])}>
          </div>
        );
      })     
    }
  );
}

对象也可以是这样(只有图像名称):

const rarities = {
  Exclusive: 'Rarity_Exclusive.png',
  Ultra: 'Rarity_Ultra.png',
}

并访问它们:

<img src={require(`../../public/${rarities[skin.rarity]}`)}>

You can change the rarities object to this (paths as values):

const rarities = {
  Exclusive: '../../public/Rarity_Exclusive.png',
  Ultra: '../../public/Rarity_Ultra.png',
}

Then you can then access the image from the object by rarity.

function KnifesComponent() {

  const knifeCollection = collection(db, "knives");
  const [knives, setKnives] = useState([]);
  
  useEffect(() => {
    onSnapshot(knifeCollection, (snapshot) => {
      setKnives(snapshot.docs.map((doc) => ({ ...doc.data(), id: doc.id })));
    });
  }, []);  

  return (
    {
      knives.map((skin) => {
        return (
          {skin.rarity} // Returns "Ultra" for Example
          <div>
            <img src={require(rarities[skin.rarity])}>
          </div>
        );
      })     
    }
  );
}

The object also can be like this (just the image names):

const rarities = {
  Exclusive: 'Rarity_Exclusive.png',
  Ultra: 'Rarity_Ultra.png',
}

And access them:

<img src={require(`../../public/${rarities[skin.rarity]}`)}>

根据数据库返回的值有条件地渲染图像源

烟若柳尘 2025-02-20 09:21:31

它可以通过调用集成环境的端池来工作,

为此,它有必要使用BadCertificateCallback并指定我想允许访问的证书。我创建了一个指定此内容的类:

class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext context) {
    return super.createHttpClient(context)
      ..badCertificateCallback = (X509Certificate cert, String host, int port) {
        if (host.isNotEmpty &&
            host == 'ec2-54-202-27-94.sa-east-1.compute.amazonaws.com') {
          return true;
        } else {
          return false;
        }
      };
  }
}

添加以下行

WidgetsFlutterBinding.ensureInitialized();
HttpOverrides.global = MyHttpOverrides();

在具有主函数的项目文件中,以这种方式

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  HttpOverrides.global = MyHttpOverrides();

    runApp(
      MyApp(),
    );
}

:不适合在生产环境中使用不安全的证书。仅在调试模式下使用

It worked for the request to work by calling the endpont of the integration environment

For this it was necessary to use the badCertificateCallback and specify the certificate that I would like to allow access. I created a class specifying this:

class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext context) {
    return super.createHttpClient(context)
      ..badCertificateCallback = (X509Certificate cert, String host, int port) {
        if (host.isNotEmpty &&
            host == 'ec2-54-202-27-94.sa-east-1.compute.amazonaws.com') {
          return true;
        } else {
          return false;
        }
      };
  }
}

And in the project file that has the main function, add the following lines

WidgetsFlutterBinding.ensureInitialized();
HttpOverrides.global = MyHttpOverrides();

This way:

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  HttpOverrides.global = MyHttpOverrides();

    runApp(
      MyApp(),
    );
}

It is not appropriate to allow the use of insecure certificates in a production environment. Use only in Debug mode

扑来 - 我可以向EC2集成环境端点提出请求

烟若柳尘 2025-02-20 01:17:46

事实证明,绝对路径的使用是一个问题,方法驱动程序:: DiagnoseInputeXistence如果文件路径以>>>>>“/”/“”而自动拒绝。

使用相对文件术解决了这个问题。

It turned out to be a problem with the usage of absolute paths, the method Driver::DiagnoseInputExistence automatically rejects the file path if it starts with "/".

Using a relative filepath solved this issue.

Clang CFE编译无法读取文件

烟若柳尘 2025-02-19 20:30:09

尝试使用具有Java 8的5.0.1版本。

5.0.1#
[Android]添加了Java 8的Gradle Build。

请在其changElog

Try using version 5.0.1 which has java 8.

5.0.1 #
[Android] Added java 8 requirement for gradle build.

Please check the same in its changelog flutter_secure_storage

fluttersecurestorageplugin.java:260:错误:-source 7中不支持方法参考

烟若柳尘 2025-02-19 18:04:13

如下所示,添加睡眠

while True:
    try:
        web_elements_names = driver.find_elements(By.CLASS_NAME,
                                                  "a-size-base-plus.a-color-base.a-text-normal")  # names (webelems)
        web_elements_prices = driver.find_elements(By.CLASS_NAME, "a-price-whole")  # prices (webelems)
        get_text_store(web_elements_names, names_txt)  # text from webelems names
        get_text_store(web_elements_prices, prices_txt)  # text from webelems prices
        WebDriverWait(driver, 10).until(
            EC.element_to_be_clickable((By.XPATH, "//a[text()='Next']"))).click()  # go to the next page
        sleep(5)
    except TimeoutException:
        print("Timeout Exception")
        break

Add a sleep as shown below

while True:
    try:
        web_elements_names = driver.find_elements(By.CLASS_NAME,
                                                  "a-size-base-plus.a-color-base.a-text-normal")  # names (webelems)
        web_elements_prices = driver.find_elements(By.CLASS_NAME, "a-price-whole")  # prices (webelems)
        get_text_store(web_elements_names, names_txt)  # text from webelems names
        get_text_store(web_elements_prices, prices_txt)  # text from webelems prices
        WebDriverWait(driver, 10).until(
            EC.element_to_be_clickable((By.XPATH, "//a[text()='Next']"))).click()  # go to the next page
        sleep(5)
    except TimeoutException:
        print("Timeout Exception")
        break

当python中的列表中附加元素时,使用时循环仅返回第一个迭代的结果

烟若柳尘 2025-02-19 09:12:35

以下代码说明了异步函数如何获得锁定,该函数可以防止并发执行,直到再次释放锁。

var locked;
function lock(req, res, next) {
  if (locked)
    locked.on("release", next);
  else {
    locked = new EventEmitter();
    next();
  }
}
function unlock() {
  if (locked) {
    locked.emit("release");
    locked = undefined;
  }
}
app.use(lock, function(req, res) {
  console.log("1");
  setTimeout(function() {
    console.log("2");
    res.end();
    unlock();
  }, 1000);
});

这将在全局变量锁定中维护JavaScript级别上的锁定。您可能需要一些更细颗粒的东西。

选择更新的数据库级别锁定也是可能的,但是如果失败了,请求必须重试直到成功,因为数据库不会发射Release> Release Event就像上面的代码一样。

The following code demonstrates how an asynchronous function can acquire a lock, which prevents concurrent execution until the lock is released again.

var locked;
function lock(req, res, next) {
  if (locked)
    locked.on("release", next);
  else {
    locked = new EventEmitter();
    next();
  }
}
function unlock() {
  if (locked) {
    locked.emit("release");
    locked = undefined;
  }
}
app.use(lock, function(req, res) {
  console.log("1");
  setTimeout(function() {
    console.log("2");
    res.end();
    unlock();
  }, 1000);
});

This maintains the lock on the Javascript level in the global variable lock. You may need something more fine-granular.

A database level lock with select for update is also possible, but if that fails the request would have to try again until it succeeds, because the database does not emit a release event like the code above.

如何防止MySQL交易在Node.js Express中同时执行?

烟若柳尘 2025-02-18 22:52:07

严格检查的最佳操作员是

if($foo === true){}

这样,您确实在检查其是否为真,而不是1或只是设置。

The best operator for strict checking is

if($foo === true){}

That way, you're really checking if its true, and not 1 or simply just set.

PHP中的真实/错误工作如何?

烟若柳尘 2025-02-18 17:47:29

我们这样做

Colors.red.withOpacity(1.1);

We do this in flutter

Colors.red.withOpacity(1.1);

如何更改颤动中的小部件亮度?

烟若柳尘 2025-02-18 13:45:28

您可以直接查询API:

对于南非: https://www.shazam.com/shazam/v3/no/no/web/web/web/web/web/web/web/web/tracks/ip-country-country-chart-chart-chart-chart-chart-za?pagessize = 200200 = 200&amp; startfrom = 0

您必须更改不同国家/地区的ip-country-part-za的部分。如果我想要挪威的图表,我将其更改为ip-country-part-no

所以这是我要做的:

response = requests.get("https://www.shazam.com/shazam/v3/en/NO/web/-/tracks/ip-country-chart-ZA?pageSize=200&startFrom=0").json()
track_data = response["tracks"]
tracks = [f'{track["title"]} - {track["subtitle"]}' for track in track_data]

You can query the api directly:

for South africa its: https://www.shazam.com/shazam/v3/en/NO/web/-/tracks/ip-country-chart-ZA?pageSize=200&startFrom=0

and you have to change the part that says ip-country-part-ZA for different countries. If i want charts from Norway i change it to ip-country-part-NO

so here is what i would do:

response = requests.get("https://www.shazam.com/shazam/v3/en/NO/web/-/tracks/ip-country-chart-ZA?pageSize=200&startFrom=0").json()
track_data = response["tracks"]
tracks = [f'{track["title"]} - {track["subtitle"]}' for track in track_data]

通过python中的ajax使用URL生成JSON文件

烟若柳尘 2025-02-18 00:20:04

由于您可以设置自己的图标,因此我们将官方示例用作基础,并仅提取要绘制的一些行。官方示例是使用folium.geojson()的标记。设置了工具提示和弹出窗口。请参阅详细信息

更新:

更新了代码和图形,正式参考中的第一个示例是我们正在寻找的内容。在这种情况下,样式引用了数据框中的列以设置标记的颜色和大小。

import os
import folium
import geopandas as gpd

rootpath = os.path.abspath(os.getcwd())
gdf = gpd.read_file(os.path.join(rootpath, "data", "subway_stations.geojson"))
gdf = gdf[gdf['line'].str.contains('Express')]
gdfs = gdf.copy()
gdfs['objectid'] = gdfs['objectid'].astype(int) 
gdfs.sort_values(['line', 'objectid'], ascending=[True, False], inplace=True)

gdfs['href'] = '<a href="' + gdfs.url + '">' + gdfs.url + "</a>"
gdfs['service_level'] = gdfs.notes.str.split(', ').apply(lambda x: len([v for v in x if "all" in v]))
gdfs['lines_served'] = gdfs.line.str.split('-').apply(lambda x: len(x))

colors = ["orange", "yellow", "green", "blue"]
service_levels = gdfs.service_level.unique().tolist()

m = folium.Map(location=[40.75, -73.95], zoom_start=12)

folium.GeoJson(
    gdfs,
    name="Subway Stations",
    marker=folium.Circle(radius=4, fill_color="orange", fill_opacity=0.4, color="black", weight=1),
    tooltip=folium.GeoJsonTooltip(fields=["name", "line", "notes"]),
    popup=folium.GeoJsonPopup(fields=["name", "line", "url", "notes"]),
    style_function=lambda x: {
        "fillColor": colors[x['properties']['service_level']],
        "radius": (x['properties']['lines_served'])*30,
    },
    highlight_function=lambda x: {"fillOpacity": 0.8},
    zoom_on_click=True,
).add_to(m)

Since you can set your own icons, we used the official example as a basis and extracted only some of the lines to be graphed. The official example is a marker using folium.Geojson(). Tooltips and popups are set up. See this for details.

UPDATE:

Updated the code and graphs, as the first example in the official reference is what we are looking for. In this case, the style references a column in the data frame to set the color and size of the marker.

import os
import folium
import geopandas as gpd

rootpath = os.path.abspath(os.getcwd())
gdf = gpd.read_file(os.path.join(rootpath, "data", "subway_stations.geojson"))
gdf = gdf[gdf['line'].str.contains('Express')]
gdfs = gdf.copy()
gdfs['objectid'] = gdfs['objectid'].astype(int) 
gdfs.sort_values(['line', 'objectid'], ascending=[True, False], inplace=True)

gdfs['href'] = '<a href="' + gdfs.url + '">' + gdfs.url + "</a>"
gdfs['service_level'] = gdfs.notes.str.split(', ').apply(lambda x: len([v for v in x if "all" in v]))
gdfs['lines_served'] = gdfs.line.str.split('-').apply(lambda x: len(x))

colors = ["orange", "yellow", "green", "blue"]
service_levels = gdfs.service_level.unique().tolist()

m = folium.Map(location=[40.75, -73.95], zoom_start=12)

folium.GeoJson(
    gdfs,
    name="Subway Stations",
    marker=folium.Circle(radius=4, fill_color="orange", fill_opacity=0.4, color="black", weight=1),
    tooltip=folium.GeoJsonTooltip(fields=["name", "line", "notes"]),
    popup=folium.GeoJsonPopup(fields=["name", "line", "url", "notes"]),
    style_function=lambda x: {
        "fillColor": colors[x['properties']['service_level']],
        "radius": (x['properties']['lines_served'])*30,
    },
    highlight_function=lambda x: {"fillOpacity": 0.8},
    zoom_on_click=True,
).add_to(m)

enter image description here

叶标记维度

烟若柳尘 2025-02-17 07:40:44

一个简单的替代方案

在您的示例中,要突出显示的部分包裹在括号中:

[text to be highlighted]

因此,您可以匹配括号并用跨度替换它们。这将更容易维护和用多种语言进行工作。

正则正则匹配括号并捕获其中的文字:

/\[(.*?)\]/g

并且我们包围捕获的文本$ 1 带有跨度:

text.replace(/\[(.*?)\]/g, `<span class="bold">$1</span>`);

您可能还想考虑使用JavaScript Markdown库,例如标记。

运行片段以了解其工作原理

function setLocale(locale) {

  let text = locale === "es" ? aboutUsText.es : aboutUsText.en;

  aboutUs.innerHTML = text.replace(/\[(.*?)\]/g, `<span class="bold">$1</span>`);
  
}

let aboutUsText = {

en: `We have more than 10 years’ experience in the sector and can offer you a professional and comprehensive real estate service. We’re here to [make your life easier], so that you can forget about the [“I have to’s”]. We can give you advice on whatever you need, whether it’s refurbishments, interior design, decoration, rental management, valuation of investments, or anything else. We’re here for you.`,

es: `Contamos con más de 10 años de experiencia en el sector y podemos ofrecerle un servicio inmobiliario profesional e integral. Estamos aquí para [hacer tu vida más fácil], para que te olvides de los [“tengo que”]. Podemos asesorarte en lo que necesites, ya sean reformas, interiorismo, decoración, gestión de alquileres, valoración de inversiones, o cualquier otro. Estamos aquí por tí.`

};


setLocale("en");
body {
  font-family: sans-serif;
  padding: 1em;
}

.bold {
  font-weight: bold;
  background-color: yellow;
}
<input type="radio" name="locale" value="en" onchange="setLocale(this.value)" checked> English
<input type="radio" name="locale" value="es" onchange="setLocale(this.value)"> Español
<p id="aboutUs"></p>

A Simple Alternative

In your example the sections to be highlighted are wrapped in brackets:

[text to be highlighted]

So you could just match the brackets and replace them with a span. This would be much easier to maintain and make work with multiple languages.

The regex matches the brackets and captures the text within:

/\[(.*?)\]/g

And we surround the captured text $1 with a span:

text.replace(/\[(.*?)\]/g, `<span class="bold">$1</span>`);

You might also want to look at using a JavaScript markdown library like Marked.js for more complex text transformations.

Run the snippet to understand how it works

function setLocale(locale) {

  let text = locale === "es" ? aboutUsText.es : aboutUsText.en;

  aboutUs.innerHTML = text.replace(/\[(.*?)\]/g, `<span class="bold">$1</span>`);
  
}

let aboutUsText = {

en: `We have more than 10 years’ experience in the sector and can offer you a professional and comprehensive real estate service. We’re here to [make your life easier], so that you can forget about the [“I have to’s”]. We can give you advice on whatever you need, whether it’s refurbishments, interior design, decoration, rental management, valuation of investments, or anything else. We’re here for you.`,

es: `Contamos con más de 10 años de experiencia en el sector y podemos ofrecerle un servicio inmobiliario profesional e integral. Estamos aquí para [hacer tu vida más fácil], para que te olvides de los [“tengo que”]. Podemos asesorarte en lo que necesites, ya sean reformas, interiorismo, decoración, gestión de alquileres, valoración de inversiones, o cualquier otro. Estamos aquí por tí.`

};


setLocale("en");
body {
  font-family: sans-serif;
  padding: 1em;
}

.bold {
  font-weight: bold;
  background-color: yellow;
}
<input type="radio" name="locale" value="en" onchange="setLocale(this.value)" checked> English
<input type="radio" name="locale" value="es" onchange="setLocale(this.value)"> Español
<p id="aboutUs"></p>

如何使用2个元素使用Regex替换?

烟若柳尘 2025-02-17 07:24:55

因此,解决方案是在“ svelte.config.js” 中设置Vite的“ configureserver” (这是 vite文档)。实施看起来像这样:

import adapter from '@sveltejs/adapter-auto';

/** @type {import('vite').Plugin} */
const viteServerConfig = {
    name: 'log-request-middleware',
    configureServer(server) {
        server.middlewares.use((req, res, next) => {
            res.setHeader("Access-Control-Allow-Origin", "*");
            res.setHeader("Access-Control-Allow-Methods", "GET");
            res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
            res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
            next();
        });
    }
};

/** @type {import('@sveltejs/kit').Config} */
const config = {
    kit: {
        adapter: adapter(),
        vite: {
            plugins: [viteServerConfig]
        }
    }
};

export default config;

So the solution was setting Vite's "configureServer" in the "svelte.config.js" (here's a link to Vite documentation). The implementation looks like this:

import adapter from '@sveltejs/adapter-auto';

/** @type {import('vite').Plugin} */
const viteServerConfig = {
    name: 'log-request-middleware',
    configureServer(server) {
        server.middlewares.use((req, res, next) => {
            res.setHeader("Access-Control-Allow-Origin", "*");
            res.setHeader("Access-Control-Allow-Methods", "GET");
            res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
            res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
            next();
        });
    }
};

/** @type {import('@sveltejs/kit').Config} */
const config = {
    kit: {
        adapter: adapter(),
        vite: {
            plugins: [viteServerConfig]
        }
    }
};

export default config;

设置横向分散的Svelte和Sveltekit

烟若柳尘 2025-02-17 06:09:42

您是否正在尝试阅读一些电子表格数据并获取嵌入式超链接?我认为PQ还无法做到这一点。您可以在电子表格中添加一个小VBA,以创建一个可以显示超链接的自定义功能,然后PowerQuery可以读取该输出

VBA:

Function GetURL(cell As Range)
    GetURL = cell.Hyperlinks(1).Address
End Function

然后

= GetURL(cell)

Are you trying to read in some spreadsheet data and grab the embedded hyperlinks? I don't think PQ is able to do that yet. You can add a small VBA into the spreadsheet to create a custom function that would show the hyperlink, then powerquery could read that output

VBA:

Function GetURL(cell As Range)
    GetURL = cell.Hyperlinks(1).Address
End Function

then

= GetURL(cell)

Excel查询&amp;连接 /电源查询不保留超链接

烟若柳尘 2025-02-17 04:32:26

AS theo 指出,因为您的意图是将除slash以外的所有单个字符分开(/)使用/,您无需找到现有斜线的索引,因为可以使用以下方式简化该方法:

# -> 'a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p'
('ab/cde/f/ghijklm/no/p' -replace '/').ToCharArray() -join '/'

使用(...) +'/'也放置/ 最后一个字符之后。或者,考虑


作为 zett42 指出,最直接的方式是直接的方式获取 - 0基于 - 字符或子弦位置是使用 [regex] :: matches() .net方法:

# -> 2, 6, 8, 16, 19
[regex]::Matches('ab/cde/f/ghijklm/no/p', '/').Index

请注意,即使方法呼叫返回,即使多个(集合)仪表信息对象,.index可用于从每个中提取索引(位置)value ,由PowerShell的便利性< a href =“ https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about/about/about_member-access_enumeration' /em> 。

As Theo points out, since your intent is to separate all individual characters other than a slash (/) with /, you don't need to find the indices of existing slashes, because the approach can be simplified to:

  • removing existing / instances, using the -replace operator

  • joining the individual characters in the result with the -join operator

    • The array of individual characters is obtained with the .ToCharArray() .NET string method below; alternatively, you could cast to [char[]]
# -> 'a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p'
('ab/cde/f/ghijklm/no/p' -replace '/').ToCharArray() -join '/'

Use (...) + '/' to also place a / after the last character. Alternatively, consider phuclv's regex-based solution.


As zett42 points out, the most direct way to obtain - 0-based - character or substring positions, is to use the [regex]::Matches() .NET method:

# -> 2, 6, 8, 16, 19
[regex]::Matches('ab/cde/f/ghijklm/no/p', '/').Index

Note that even though the method call returns multiple (a collection of) match-information objects, .Index can be used to extract the index (position) value from each, courtesy of PowerShell's convenient member-access enumeration feature.

如何在字符串中保存某些字符的所有位置?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文