如何在剃须刀视图页面中获取检查文件 [英] how to get check file contains in razor view page

查看:82
本文介绍了如何在剃须刀视图页面中获取检查文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何检查变量是否包含扩展名,

我定义为var file = file1.prj。

我想在java脚本中检查变量是否包含prj。

我该怎么做


how to check the variable contains the extension or not,
I defined like var file = file1.prj.
I want to check whether the variable contains prj or not in java script.
how can I do this

推荐答案

步骤:

1.基于''。''作为分隔符,将变量拆分为数组

2.如果确定变量的格式始终为xxx,请检查第二个值。 yyy

3.如果数组长度大于1,则根据定义的格式,变量包含扩展名。



参考: JavaScript split()方法 [ ^ ]



试用。
Steps:
1. Based on ''.'' as a delimiter, split the variable into array
2. Check the 2nd value if you are sure that variable will always be of format xxx.yyy
3. If array length is more than one, based on the defined format, variable contains extension.

Refer: JavaScript split() Method[^]

Try out.


这篇关于如何在剃须刀视图页面中获取检查文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆